Leaflet / Leaflet.Editable

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

Layers are no longer draggable after being toggled #192

Open danmichaelo opened 5 years ago

danmichaelo commented 5 years ago

It seems like editable layers are no longer draggable after being toggled by Layers Control or by other means.

To demonstrate the issue, I modified (diff) the basic example by adding the editable layers to a LayerGroup that can be toggled using Layers Control:

https://danmichaelo.github.io/Leaflet.Editable/example/

To reproduce the issue:

  1. Use the Layers Control on the right to hide, then show the "Editing layer"
  2. Try dragging any of the editable shapes

Result: They are no longer draggable. The vertices can still be dragged though.

Update: Layers Control uses Map.removeLayer(layer) and Map.addLayer(layer) to toggle things, so I created a slightly more minimal example demonstrating the issue here:

https://danmichaelo.github.io/Leaflet.Editable/example/minimal.html

Also created two tests:

https://github.com/danmichaelo/Leaflet.Editable/commit/36d15b510dc778307bb728c0a90700c8e2f07dfc

The first one passes (when using layer.disableEdit(); layer.enableEdit();), the second one fails (when using this.map.removeLayer(layer); this.map.addLayer(layer);). Calling layer.disableEdit(); before removing the layer also doesn't seem to help.

ssontag55 commented 3 years ago

@danmichaelo You find a work around on this? I have a clear all layers option on the map, and once I've done this I can't enable editing again. I've gotten so that it works if I don't clear canvas layers but separating panes don't matter.

johandanforth commented 9 months ago

@danmichaelo I stumbled on this problem to. After a map.removeLayer(featureGroup) and a map.addLayer(featureGroup), dragging is no longer working. I can still edit the points of a polyline, but dragging is not working. I suspect the error lies in the Path.Drag.js and not in Leaflet.Editable