Leaflet / Leaflet.Editable

Make geometries editable in Leaflet.
http://leaflet.github.io/Leaflet.Editable/doc/api.html
559 stars 197 forks source link

Moving a circle through JS doesn't move the controls #176

Open DOFandersolsen opened 6 years ago

DOFandersolsen commented 6 years ago

I have a map section where the user can place a circle and resize the radius to indicate an area of the map.

When the user single-clicks outside the map, I want the circle to move so the center is where the mouse click happened.

This works, but the white boxes for the resize-controls are left behind.

Code:

//The click is outside the bounds, so if the circle exists, we move it to that center
    if (circle) {
      circle.setLatLng(coordinates);
    } else {
      circle = L.circle(coordinates, { radius: radius });
      circle.addTo(map);
      circle.enableEdit();
    } 

It gives me this result however: skaermbillede 2018-09-17 kl 17 21 27

I know I can fix it by removing the circle, adding it again at the new position with the same radius, but I thought this is an unintended effect

magnuswikhog commented 4 years ago

A slightly better option than removing and adding the circle again is to call disableEdit() and then enableEdit(). Calling reset() didn't move the resize handle for me.