Openlayers 3 获取GML选项错误

Openlayers 3 获取GML选项错误,openlayers-3,Openlayers 3,我正在尝试创建wfs-t服务,我使用了ol.format.wfs#writeTransaction方法并序列化了wfs-t XML,但我的jslint总是在GML格式选项处出现预览错误。是否可能是我错误地初始化了ol.format.WFS对象 或者可能我将错误的选项传递给writeTransaction方法?或者可能是OpenLayers4中的一个bug?以下是我使用angular http服务的wfs-t服务的详细信息: private _transactWFS(feature: any, o

我正在尝试创建wfs-t服务,我使用了ol.format.wfs#writeTransaction方法并序列化了wfs-t XML,但我的jslint总是在GML格式选项处出现预览错误。是否可能是我错误地初始化了ol.format.WFS对象

或者可能我将错误的选项传递给writeTransaction方法?或者可能是OpenLayers4中的一个bug?以下是我使用angular http服务的wfs-t服务的详细信息:

private _transactWFS(feature: any, operation: any): any {

    let payload;

    try {
        const formatWFS = new ol.format.WFS({});
        const formatGML = new ol.format.GML({
            featureNS: operation.featureNS,
            featureType: operation.featureType,
            srsName: operation.srsName
        });
        const xs = new XMLSerializer();
        let node: any = null;
        switch (operation.mode) {
            case 'insert':
                node = formatWFS.writeTransaction([feature], null, null, formatGML);
                break;
            case 'update':
                node = formatWFS.writeTransaction(null, [feature], null, formatGML);
                break;
            case 'delete':
                node = formatWFS.writeTransaction(null, null, [feature], formatGML);
                break;
        }

        payload = xs.serializeToString(node);
    } catch (error) {}

    return payload;
}
lint消息:

 [ts]
Argument of type 'GML' is not assignable to parameter of type 'WFSWriteTransactionOptions'.
Property 'featureNS' is missing in type 'GML'.
从:


似乎表明您生成的WFS对象错误。

我放弃使用WFS格式生成WFS事务请求,因此我的问题由我自己解决,我找到了这个库。这个图书馆非常适合解决我的问题。

请阅读-总结是,这不是解决志愿者问题的理想方式,可能会对获得答案产生反作用。请不要将此添加到您的问题中。实际上,此错误仅在我使用typescript时出现,尤其是在GML格式选项中。我指定的所有属性都像功能一样,通常认为writeTransactionOptions未指定。
        // Word to the Wise from an anonymous OpenLayers hacker:
        //             
        // The typename in the options list when adding/loading a wfs 
        // layer not should contain the namespace before, (as in the 
        // first typename parameter to the wfs consctructor).
        // 
        // Specifically, in the first parameter you write typename: 
        // 'topp:myLayerName', and in the following option list 
        // typeName: 'myLayerName'. 
        // 
        // If you have topp included in the second one you will get 
        // namespace 14 errors when trying to insert features.
        //
        wfs = new OpenLayers.Layer.WFS(
            "Cities",
            "http://sigma.openplans.org/geoserver/wfs",
            {typename: 'topp:tasmania_cities'},
            {
                typename: "tasmania_cities",
                featureNS: "http://www.openplans.org/topp",
                extractAttributes: false,
                commitReport: function(str) {
                    OpenLayers.Console.log(str);
                }
            }
        );