Leaflet / Leaflet.markercluster

Marker Clustering plugin for Leaflet
MIT License
3.98k stars 1k forks source link

Marker disappears from parent layer after setting marker new coordinates #1091

Open rsnow67 opened 1 year ago

rsnow67 commented 1 year ago

How to reproduce

Steps:

  1. Initialize map
  2. Сreate new markerClusterGroup
  3. Add markerClusterGroup to map by addTo()
  4. Create new marker
  5. Add this marker to markerClusterGroup by addLayer()
  6. Try to get marker by getLayer() from markerClusterGroup – you'll get it
  7. Remove markerClusterGroup from map by removeLayer()
  8. Set marker new coordinates by setLatLng()
  9. Try to get marker by getLayer() from markerClusterGroup – you'll get null
  10. Re-add markerClusterGroup to map
  11. Try to get marker by getLayer() from markerClusterGroup – you'll get it (all code below)

What behaviour I'm expecting and which behaviour I'm seeing

I expect that after setting marker new coordinates I can get marker by getLayer() method before I re-add parent layer to map, but I get null.

Minimal example reproducing the issue

https://plnkr.co/edit/UUuWoMVgk85eyHQk