I have a circle that I add to the map when you click on a specific point (centroid of that circle will be where the point is) and you can edit the circle, meaning you can resize it using the gripper on the end of the circle:
The resizing is working fine but what I want to do is prevent the circle from being draggable:
How do I disable dragging the circle but still keep the resizing? I am using the leaflet-draw library and as well as @types/leaflet-draw packages. And here is how I am adding the circle to the map:
onMapClick(leafletMouseEvent: LeafletMouseEvent) {
const drawControl = new L.Control.Draw({
draw: {
circle: true, // Enable circle drawing
},
edit: {
featureGroup: new L.FeatureGroup()
}
});
map.addControl(drawControl);
// Initialize the feature group for drawn items
drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
map.on(L.Draw.Event.CREATED, (e: any) => {
let layer = e.layer;
drawnItems.addLayer(layer); // Add shape to current drawing
});
map.on(L.Draw.Event.EDITED, (e: any) => {
let layers = e.layers;
layers.eachLayer((layer: any) => {
drawnItems.addLayer(layer);
});
});
const circle: any = new L.Circle(latLng, {
radius: 1609.34, // 1 mile in meters
});
drawnItems.addLayer(circle);
circle.editing.enable()
}