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

Popups bound to instances of FeatureGroup are discarded when extracting points from layers. #970

Open
5 tasks done
Sam152 opened this issue Nov 20, 2019 · 2 comments
Open
5 tasks done

Comments

@Sam152
Copy link

Sam152 commented Nov 20, 2019

  • 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

How to reproduce

  • Leaflet version I'm using: latest stable

  • Leaflet.MarkerCluster version I'm using: latest tagged

  • Browser (with version) I'm using: all browsers

  • OS/Platform (with version) I'm using: OSX

  • Create a LayerGroup, add some items to it.

  • Bind a popup to the layer group.

  • Add the layer group to a cluster and add the cluster to a map.

  • Any popup bound to the LayerGroup is discarded when non-group layers are extracted in addLayers.

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

It would be good if things bound to the group are transferred to child layers as they are extracted. I have only reproduced this with a popup but I imagine the same might apply to events and other methods.

Minimal example reproducing the issue

  • this example is as simple as possible
  • this example does not rely on any third party code

Here is a simple way to reproduce the issue:

https://plnkr.co/edit/lbtWnmaBILmvrWYB8ARp

@Sam152 Sam152 changed the title Popups bound to instances of LayerGroup are discarded when extracting points from layers. Popups bound to instances of FeatureGroup are discarded when extracting points from layers. Nov 20, 2019
@ghybs
Copy link
Contributor

ghybs commented Nov 25, 2019

As you noticed, unfortunately a MarkerClusterGroup does not keep track of the Layer Groups.

However a simple workaround is to use your Group eachLayer method to assign the popup individually to each child layer.

@Sam152
Copy link
Author

Sam152 commented Nov 25, 2019

What do you think to the approach in #971?

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

2 participants