geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

strange behaviour when dragging clustered markers #1337

Closed forgotten-map closed 1 year ago

forgotten-map commented 1 year ago

I noticed a strange behaviour when I try to edit/drag markers that are clustered with leaflet.markercluster. I'm able to drag the marker around, but for some strange reason, it moves slightly less than where the mouse cursor is, and it's more noticeable the far it's moved from the initial point.

Here's a jsfiddle that reproduces the issue: https://jsfiddle.net/2dL0rz3j/11/

Falke-Design commented 1 year ago

We don't support to drag a whole MarkerClusterGroup. What would be the result? Moving all Markers together and keeping the distance between them all? What happens if a user zooms while dragging?

For a better integration take a look into #864.

Attention in your demo you are only moving the MarkerClusterGroup-Icon and not the markers: https://jsfiddle.net/e7ma9vqh/

markercluster-drag

forgotten-map commented 1 year ago

We don't support to drag a whole MarkerClusterGroup. What would be the result? Moving all Markers together and keeping the distance between them all? What happens if a user zooms while dragging?

No, the intention was not to move the whole MarkerClusterGroup, the intention was to move a single marker that was part of the MarkerClusterGroup. Looking at your jsfiddle it seems that I have to remove the marker/layer from the MarkerClusterGroup (and re-add it to the map) to be able to edit it properly. I'll give it a try, it might work for me.

Falke-Design commented 1 year ago

@forgotten-map if you want to move a single marker use the code from #864.

forgotten-map commented 1 year ago

@forgotten-map if you want to move a single marker use the code from #864.

Actually running the demo in https://github.com/geoman-io/leaflet-geoman/discussions/864. (https://jsfiddle.net/ayhsmjzn/) I see exactly the same issue I described above, the marker can be dragged around, but it's moved slightly less than the position where the mouse cursor is Let me try to include a video here: ezgif-2-300c81f5da

The only thing that seems to be working is to remove the marker from the cluster, and add it to the map again, as in your https://jsfiddle.net/e7ma9vqh/ The problem in my case is that I use, L.markerClusterGroup.layerSupport, and even if I remove the marker from the cluster, as soon I add it to the map, since it belongs to the L.layerGroup that makes the cluster, it's automatically added back to the cluster. I'll see if I manage to avoid the use of the L.markerClusterGroup.layerSupport subplugin, or figure some other way