我怎么可以编辑webworldwind层?

问题描述 投票:0回答:1

我现在用的是webworldwind显示由GeoServer的发表我的矢量图层,我怎样才能将它们活跃编辑?例如,我可以删除我的观点矢量图层的点?每个响应ID欣赏!

edit layer webworldwind
1个回答
0
投票

现在的问题是缺少大量的相关信息。我会认为你集成在GeoServer的矢量层,然后你显示经由WMS协议的层。

如果是这种情况,那么就需要在控制器的组合来侦听的点击,然后使用WFS协议(https://docs.geoserver.org/stable/en/user/services/wfs/reference.html)来改变层。下面的函数说明如何可以得到给定的点的功能。

function getFeaturesForPoint(url, layerNames, point) {
    // The URL will look something similar to http://localhost/geoserver/workspace/wfs
    var url = url + '?service=wfs&version=1.1.0&request=GetFeature&typeNames='+layerNames+'&FILTER=' +
        '<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>the_geom</PropertyName><gml:Point srsName="EPSG:4326"><gml:coordinates>'+point.longitude+','+ point.latitude + '</gml:coordinates></gml:Point></Intersects></Filter>' +
        '&outputFormat=application/json';

    return fetch(url, {
            method: 'GET',
            credentials: 'include',
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json'
            }
    }).then(function(response){
            return response.json();
    }).then(function(feature){
        if (data.type === 'FeatureCollection' && data.features && data.features.length) {
            return data.features;
       } 
   });
}

此函数接受的GeoServer到WFS端点对于给定的工作区和一个点由纬度和经度所定义的URL,并返回对在格式层1层给定点的所有功能,二层(可以仅提供一个层) 。该功能为您提供了随后的WFS请求,如要素的ID关键信息。

要删除下面的函数的点示出了具有WFS事务请求的例子。上面有链接的GeoServer的文档中更多的例子。

function deleteFeature(url, layerName, featureId) {
    // The URL will look something similar to http://localhost/geoserver/workspace/wfs
    return fetch(url, {
            method: 'POST',
            credentials: 'include',
            headers: {
                'Content-Type': 'application/xml',
                'Accept': 'application/json'
            },
            body: '<wfs:Transaction service="WFS" version="1.0.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs"><wfs:Delete typeName="'+layerName+'"><ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>'+featureId+'</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter></wfs:Delete></wfs:Transaction>'
    }).then(function(response){
        return response.json();
    });
}
© www.soinside.com 2019 - 2024. All rights reserved.