0

The Esri-Leaflet sample map Editing feature layers shows how the geometry of an ArcGIS Server feature layer can be created in Leaflet, by digitising a new polygon which is inserted into the feature layer.

Is it possible to set the attributes of the newly created feature?

This code inserts the new feature into the feature layer: pedestrianDistricts.addFeature(e.layer.toGeoJSON())

Examining the value of e.layer.toGeoJSON() in the debugger I can see that there are no properties (ie attributes) on the editable layer. Is it possible to pass the desired attributes while creating the geometry, during the addFeature?

1 Answer 1

1

As always, I spent ages on this problem then figured out the answer immediately after posting the question on GIS SE.

One simple solution is to first convert the layer to GeoJSON, amend this by adding the required value, then continue with the addFeature using the amended GeoJSON:

map.on('editable:drawing:commit', function (e) { var layerJSON = e.layer.toGeoJSON(); layerJSON.properties['PEDDISTRIC'] = 'blah'; pedestrianDistricts.addFeature(layerJSON); });

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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