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

Layers are no longer draggable after being toggled

Open danmichaelo opened this issue 6 years ago • 2 comments
trafficstars

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.

danmichaelo avatar Sep 08 '19 17:09 danmichaelo

@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.

ssontag55 avatar May 25 '21 17:05 ssontag55

@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

johandanforth avatar Jan 22 '24 14:01 johandanforth