0

I'm trying to use the esri-leaflet example on editing (https://esri.github.io/esri-leaflet/examples/editing.html) to edit two different featureLayers.

First when I add a point with leaflet draw, I want it to automatically create a buffer around the point. I can get it to add the circle in 'draw:created' by pulling the points (lat & lng) from the marker and giving it a radius.

 map.on('draw:created', function (e) {
    // add the feature as GeoJSON (feature will be converted to ArcGIS JSON internally)
    collectionBoxes.addFeature(e.layer.toGeoJSON());
   //  createBuffer using the lat lng from marker added by leaflet draw
    var circle = L.circle([e.layer._latlng.lat, e.layer._latlng.lng], 304.8).addTo(drawnItems);
   // try to add buffer to arcgis service
    buffers.addFeature(circle.toGeoJSON());
    disableEditing = false;
});

This line adds a circle on the map.

var circle = L.circle([e.layer._latlng.lat, e.layer._latlng.lng], 304.8).addTo(drawnItems);

This line does not give any errors.

'buffers.addFeatures(circle.toGeoJSON);'

but does not edit the arcgis service for the buffer. The point layer (collectionBoxes) does get edited. Any ideas on this or how to edit the example to edit two layers?

1

from the Leaflet documentation:

L.circle.toGeoJSON() Returns a GeoJSON representation of the circle marker (GeoJSON Point Feature).

Since calling this method returns a point, the returned object would only be valid input geometry to pass to an ArcGIS feature service with the same corresponding geometry type.

Check out this stack overflow article to learn more about creating polygons from circle geometries in client logic.

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.