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

Evented leaflet objects that are added while polylinemeasure is toggled on are improperly handled

Open shawncrobinson opened this issue 2 years ago • 2 comments

The curent implementations of _savePolylineEvents and _saveNonpolylineEvents are unable to account for adding evented leaflet objects to the map while Leaflet.PolylineMeasure is toggled on.

If an evented object is added while toggled on, it can be interacted with and steal clicks from polylinemeasure objects. Then when toggled off, the evented object is unable to be interacted with.

In my project, I'm re-creating leaflet markets whenever I receive updates on them. I am unable to change this. I've implemented a hacky workaround by:

  • intercepting click events at a high z-index (like this solution from leaflet-measure's community)
  • moving all of leaflet.polylinemeasure's leaflet map objects above the intercepting layer.
  • changing _savePolylineEvents and _saveNonpolylineEvents to only add and remove Leaflet.PolylineMeasure owned objects from _map._targets (since saving nonpolyline events is no longer necessary while intercepting clicks at a higher z-index)

shawncrobinson avatar Aug 09 '22 01:08 shawncrobinson

Hi, if you have an idea on how to solve this issue on your project, feel free to provide a PR for PolylineMeasure.

ppete2 avatar Aug 09 '22 07:08 ppete2

Sounds good, I'll try to get a PR in over the weekend.

shawncrobinson avatar Aug 11 '22 15:08 shawncrobinson