-
Notifications
You must be signed in to change notification settings - Fork 987
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
Markercluster doesn't appear in order in the Layers control as an Overlay #422
Comments
overlays is a map not an array, so the ordering isn't guaranteed. |
Excuse my ignorance, but could you expand on what you mean please? Especially 'overlays is a map not an array'. I'd already checked the leaflet forum & autoZIndex appears to be working as stated with layergroups. As I see it (though probably wrong), overlays are a collection of data in layergroups. (From the Leaflet markercluster blog: "...just replace your existing LayerGroup usage with an L.MarkerClusterGroup"). |
I mean that the order of items in a If you want to guarantee ordering I think you need to use these: |
OK. I maybe misunderstanding. I thought the autoZIndex:true, option was implemented to overcome the order problem. |
autoZIndex is just for making the layers on the map have z-index values that line up with their order in the layers list: Does the ordering really not work correctly when adding layers one at a time? A jsfiddle to reproduce this would be good. |
http://jsfiddle.net/m3vcqxht/2/ The Clustergroup (Pubs) is second in the js code but is first in the control. If Pubs is created with a standard layer group it remains second. |
Weird. Definitely seems like a bug somewhere, not sure what is broken though! |
Hi, Apologies again for commenting an old thread... Here is the reason for this behaviour:
Fork of DaveF63's last fiddle to highlight the above behaviour: http://jsfiddle.net/Louh70wa/1/ Forcing a predefined list order in Layers Control could be done by stamping the groups in advance on purpose: http://jsfiddle.net/Louh70wa/2/ |
Well, I actually overlooked bullet 2: this ordering still depends on the JavaScript engine good will rather than a spec, so even stamping in advance to try forcing the order may not give the expected result. Looks like there is no other choice than customizing the Layers Control implementation if we really want to ensure a given order. |
Thanks for looking in to this @ghybs |
Hi, how to order the markers, even though I added them serially it is not getting displayed in order. The markers are not arranged like 1,2,4,5,6,7 but 1,2,7,6,5,4. Please find the below screenshot. How to resolve it ?
|
Hi
I have various layer groups, but only 'PubsGroup' is created with markercluster. As you can see in the overlays list it's at the bottom, but when I run the code it puts it at the top of the Layer control. If I create Pubsgroup as a standard LayerGroup it remains in its place at the bottom.
Is there solution for this?
Here's snips> of my code:
The text was updated successfully, but these errors were encountered: