Open danmichaelo opened 5 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.
@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
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:
Result: They are no longer draggable. The vertices can still be dragged though.
Update: Layers Control uses
Map.removeLayer(layer)
andMap.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 usingthis.map.removeLayer(layer); this.map.addLayer(layer);
). Callinglayer.disableEdit();
before removing the layer also doesn't seem to help.