0

I have a shapefile hosted as Feature Layer at ESRI Server.

I create a Leaflet application where I want to enable an attributes update of my Feature Layer (field 'Status'). I have customized a popup where users can choose an attribute value from the list. This value has to be sent to the server as soon as they click the "OK" button.

I tried to make use of Ajax. Console log returns an updated attribute, however I can not see any changes when I look at the data at ESRI Server.

Probably UpdateFeature function works only with geometry.

var net = L.esri.featureLayer({ url: netURL}).addTo(map);

var status_content = '<form role="form" id="form" enctype="multipart/form-data" onsubmit="addMarker()">'+
                  '<p style="font-size:12px;"><b>Update status</b></p>'+
                  '<div>'+
                      '<select class="form-control" id="st" name="new_status">'+
                        '<option value="etab">Established</option>'+
                        '<option value="plan">Planned</option>'+
                        '<option value="default">Default</option>'+
                      '</select>'+ 
                  '</div>'+
                  '<div align="right" >'+
                  '<button type="button" title="Save new status" class="ok" id="OK"><img src="ok.png"></button>'+
                  '</div>';

net.on('click', function(e) {
       net.bindPopup(status_content);
       e.layer.openPopup();
       $(document).ready(function(){
          $("#OK").click(function(){
              e.layer.feature.properties["Status"] = $("#st").val();
              net.updateFeature(e.layer.feature.properties.Status);
              console.log (e.layer.feature.properties.Status);
              e.layer.closePopup(); 
              });
          });
    });
0

I have figured it out myself.

It started to work as soon as I changed the line

net.updateFeature(e.layer.feature.properties.Status);

to

net.updateFeature(e.layer.feature);

You have also be sure that the hosted Feature Layer is open for editing (updating of attributes in my case). This can be done via Layer Setting at ArcGIS Server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.