-
Notifications
You must be signed in to change notification settings - Fork 990
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
MarkCluster with Leaflet layers #543
Comments
I'm not totally sure what you are up to, but you probably need to add/remove the layers from the MarkerClusterGroup rather than the map? |
What i try to achive is make MarkerCluster work with an layersGroup from leaflet, like in this examples: http://bl.ocks.org/ismyrnow/6123517 So in my code I create MarkerCluster function then i add them to my markers and map
but at the same time I add my marker to my layersGroup So when I click allMarkers checkbox on map legenda, the markers aggregated by cluster are still visible. I didn't find any examples of MarkClusters used with layersGroup so i wonder if is possible.. |
Hi, Please do you still have troubles in using MarkerClusterGroup? If my understanding is correct, you simply want a control overlay (of type First of all, be very cautious when adding markers to more than one layerGroup, especially a markerClusterGroup (which is a layerGroup as well). The latter will fiddle a lot with it, as you noticed. Instead, why not simply adding your MarkerClusterGroup This way, your controlLayers should show/hide everything inside Finally, if Please note that in the case of the example you mention, there are several overlays in the controlLayers. If you want to achieve something similar but with MarkerClusterGroup, you will need 1 instance of MarkerClusterGroup per desired overlay. They will not be able to cluster markers from one each other. The way Hope this helps. |
I apologize for commenting again on this closed thread, but it is just to refer to #13 which I think is a good solution for the "complex" use case of using a layers control (or external UI) to add/remove markers from a single MCG. |
Hey @ghybs thank for the answer. I already fix my problems time ago but since when i was researching for my issue i found many imilar quetsions but really few answers, i thinkis a good documentation for the future and hopefullly for other people. At the end, as you just suggested, i created many different layers, and add/remove MCG to each of them. Honestly the code wasn't very beautiful nor very modular. |
hello! I'm using your amaz plugin for my map but now that i intriduced layers everything get messed up.
Clusters add markers directly to the map not connecting them with my layers, that means when I click on layer to show/hide markers, i still see some markers, the one that were aggregated.
Any idea/examples how to deal with that?
What i do is in my createMarkers function:
The text was updated successfully, but these errors were encountered: