I am using Leaflet.Draw to draw a circle.
var circle = L.circle(new L.LatLng(latitude, longitude), number, circle_options).addTo(featureGroup);
I need the coordinates of the circle as a polygon (LatLng[]
).
Is it possible?
leafletleaflet-draw
I am using Leaflet.Draw to draw a circle.
var circle = L.circle(new L.LatLng(latitude, longitude), number, circle_options).addTo(featureGroup);
I need the coordinates of the circle as a polygon (LatLng[]
).
Is it possible?
Best Answer
Leaflet draws a circle using SVG. For example:
Results in the following html:
My guess is that there is no direct way to access the "coordinates" through Leaflet - this is done in the browser with SVG from a center point and a radius.
If you need access to coordinates, you could approximate a circle with a
L.Polygon
, using the following code adapted from here:Note radius is in miles in this example. Increase or decrease the number of points as needed.