Leaflet.Editable
Leaflet.Editable copied to clipboard
Limit radius of editable circle
I can't find a way to limit the radius of an editable circle. For example, I want the smallest possible radius to be 1000 meters, and if the user tries to make it smaller the radius just stays at 1000 meters.
I looked at cancelable events in the API documentation, but I can't see any that would fit my use case.
Hi, set limit like this.
mapEventHandler(evt: Leaflet.LeafletEvent) {
if (evt.type === 'editable:vertex:dragend' || evt.type === 'editable:vertex:drag') {
if (circle.getRadius() > 1000)
circle.setRadius(1000);
Do you have a good way to limit the size of rectangles?
Hi, set limit like this.
mapEventHandler(evt: Leaflet.LeafletEvent) { if (evt.type === 'editable:vertex:dragend' || evt.type === 'editable:vertex:drag') { if (circle.getRadius() > 1000) circle.setRadius(1000);
Its good, but there was still a problem. Marker no longer follows the circle.
https://github.com/Leaflet/Leaflet.Editable/assets/147351/4269b9e3-39a5-4bcc-9037-4f0952ccd83d
https://github.com/Leaflet/Leaflet.Editable/issues/204#issuecomment-1766495572
The only workaround I have found so far is to call
disableEdit()
before andenableEdit()
after changing bounds. This does not allow changing bounds in real time and only reliably works ondragend
andeditable:vertex:dragend
events.
I tried this, but it difficult to operate.