I am looking for ideas/libraries that enable snapping when I create a circle with leaflet draw. There is the libaray Leaflet snap, that enables snapping of draggable markers to polylines and other layers. But I am looking for an option to snap to markers when creating a circle. So basically create a circle around the marker.
1 Answer
Did you find a solution?
I've created a function which does this for me.
function mapToPosition(position){
lon = position.coords.longitude;
lat = position.coords.latitude;
var marker = new L.Marker([lat,lon],{title: "Not at the right spot? Drag me!"}).addTo(map);
marker.dragging.enable();
marker.on('dragend', function(e){
var coords = e.target.getLatLng();
var lat = coords.lat;
var lon = coords.lng;
map.panTo({lon:lon,lat:lat})
map.removeLayer(cir);
cir = L.circle([lat,lon],1000).addTo(map).bindPopup("Area within 1km of your point.");
});
cir = L.circle([lat,lon],1000).addTo(map);
}
I hope that helps!