Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setLatLng adds marker back to map when hidden using LayerControl #1096

Open
3 tasks done
divadsn opened this issue Jan 15, 2024 · 0 comments
Open
3 tasks done

setLatLng adds marker back to map when hidden using LayerControl #1096

divadsn opened this issue Jan 15, 2024 · 0 comments

Comments

@divadsn
Copy link

divadsn commented Jan 15, 2024

  • I'm reporting a bug, not asking for help
  • I'm sure this is a Leaflet.MarkerCluster code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • I've searched through the issues to make sure it's not yet reported

  • Leaflet version I'm using: 1.9.4
  • Leaflet.MarkerCluster version I'm using: latest from master
  • Browser (with version) I'm using: Firefox 121 (although it's not a browser related issue)
  • OS/Platform (with version) I'm using: Windows 10

How to reproduce

  • Create a map and add markerClusterGroup
  • Create LayerControl with L.Control.Layers and add to map
  • Add layerGroup to MCG and LayerControl
  • Create new marker, add to layerGroup
  • Hide the layer using the LayerControl
  • Change the latlng of the marker to map.getCenter() for example
  • The marker will re-appear despite the layer being hidden!

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

I've reproduced the same using the LayerControl demo, the marker did not re-appear using the same approach from above.

I found this to be the cause of the bug: https://github.com/Leaflet/Leaflet.markercluster/blob/master/src/MarkerClusterGroup.js#L716

This causes the layer to be re-added, without checking if it's added or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant