MarkerClusterGroup._addLayer attaches dragstart, move and dragend event handlers to each marker:
layer.on(this._childMarkerEventHandlers, this);
The handlers are removed in removeLayer() but NOT in removeLayers(). This is problematic if the marker is later reused by adding it to a different MarkerClusterGroup because the event handlers each have a reference to the MarkerClusterGroup in their context state. Once the marker has been added to the other group, at some point it is reassociated with the original group due to the event handler references.
A simple workaround is to detach the handlers from the marker (but of course this uses an internal implementation detail (_childMarkerEventHandlers) that should probably not be depended on):
marker.off(clusterMarkerGroup._childMarkerEventHandlers, clusterMarkerGroup);
Adding the above to MarkerClusterGroup.removeLayers() would resolve the issue.
This is occurring in leaflet.markercluster v1.5.3 (latest at time of writing)
MarkerClusterGroup._addLayer attaches dragstart, move and dragend event handlers to each marker:
layer.on(this._childMarkerEventHandlers, this);The handlers are removed in removeLayer() but NOT in removeLayers(). This is problematic if the marker is later reused by adding it to a different MarkerClusterGroup because the event handlers each have a reference to the MarkerClusterGroup in their context state. Once the marker has been added to the other group, at some point it is reassociated with the original group due to the event handler references.
A simple workaround is to detach the handlers from the marker (but of course this uses an internal implementation detail (_childMarkerEventHandlers) that should probably not be depended on):
marker.off(clusterMarkerGroup._childMarkerEventHandlers, clusterMarkerGroup);Adding the above to MarkerClusterGroup.removeLayers() would resolve the issue.
This is occurring in leaflet.markercluster v1.5.3 (latest at time of writing)