我正在开发一个Web应用程序,我需要更新来自geoserver的功能的属性。我尝试使用下面的代码更新属性信息。
this.update = function(p,f) {
var formatWFS = new ol.format.WFS();
var formatGML = new ol.format.GML({
featureNS: 'http://www.openplans.org/topp', /*namespace URI */
featureType: 'MultiPolygon',
srsName: 'EPSG:3857'
});
switch (p) {
case 'update':
node = formatWFS.writeTransaction([f], null, null, formatGML);
break;
}
s = new XMLSerailizer();
str = s.serializeToString(node);
$.ajax('http://localhost:8080/geoserver/wfs', {
type: 'POST',
dataType: 'xml',
processData: false,
contentType: 'text/xml',
data: str
}).done();
}
点击事件
<div class="btn-group">
<button class="btn btn-default" ng-disabled="ctrl.saveFeature" ng-click="ctrl.update('update',ctrl.selected_property['layer']['features'])"><span class="fa fa-save"></span> Update</button>
</div>
ctrl.selected_property [&#39; layer&#39;] [&#39;功能&#39;]将在以下结构中
0:
$$hashKey: "object:271"
geometry: {type: "MultiPolygon", coordinates: Array(1)}
geometry_name: "the_geom"
id:"tn_naturals.377"
properties:
NAME:""
TYPE:"forest123"
type:"Feature"