0

i am developing a web application where i need to update the attribute of a feature coming from geoserver. I tried updating the attribute information using below code.

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();

    }

And the click event

 <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>

Where ctrl.selected_property['layer']['features'] will be in the below structure

0:
  $$hashKey: "object:271"
  geometry: {type: "MultiPolygon", coordinates: Array(1)}
  geometry_name: "the_geom"
  id:"tn_naturals.377"
  properties:
    NAME:""
    TYPE:"forest123"
    type:"Feature"
User123
  • 793
  • 4
  • 10
  • 28

0 Answers0