Leaflet.Editable icon indicating copy to clipboard operation
Leaflet.Editable copied to clipboard

Limit radius of editable circle

Open magnuswikhog opened this issue 4 years ago • 3 comments

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.

magnuswikhog avatar May 19 '20 18:05 magnuswikhog

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);

HIRANO-Satoshi avatar Jun 12 '20 22:06 HIRANO-Satoshi

Do you have a good way to limit the size of rectangles?

HIRANO-Satoshi avatar Jun 12 '20 22:06 HIRANO-Satoshi

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 and enableEdit() after changing bounds. This does not allow changing bounds in real time and only reliably works on dragend and editable:vertex:dragend events.

I tried this, but it difficult to operate.

iyuuya avatar Nov 01 '23 01:11 iyuuya