I have a simple Leaflet map, where The user can draw a Circle, using Leaflet.Draw.
When you use the following code to get the geometry,
map.on(L.Draw.Event.CREATED, function (event) {
var layer = event.layer;
console.log(layer.toGeoJSON());
drawnItems.addLayer(layer);
});
You get only the center Point. This issue on Github says that it is expected behavior.
The issue says that you can also get the Radius, and build the Geometry yourself.
I tried to do that using Turf, using
TurfBuffer(t.circle_layer.toGeoJSON(), t.circleBounds.radius, {
units: 'meters',
});
The problem is that the circle created, is different from the Geometry shown on the Leaflet Map. (note the Road intersection on the South-East Side of the circle)
Circle on Screen where user is drawing:
Circle, which is result of Turf buffer:
I guess this is due to the radius being in Web Mercator in leaflt-draw.
I would like to get the circle coordinates that the user has actually drawn. How can I get those?
Best Answer
Here is a complete page, showing Turf Circle and Turf Buffer, the buffer shows an issue. Note the circle has steps (Vertices). I'm guessing as there isn't a real GeoJSON circle in the standard.