Layer Ordering - How to "sort" geojson layer?

170 views
Skip to first unread message

Cosme Benito

unread,
Jan 26, 2015, 10:53:10 AM1/26/15
to leafl...@googlegroups.com
Hello,

I am trying to change the display orders of the leaflet layers. I am using the setZIndex function which seems to work great for everything but geojson layers, even when I "wrap it" with a LayerGroup.

This fiddle tries to show the problem. I added the USA states two times: one where all states are red and other where all states are white. I am most likely missing something because I cannot sort them with setZIndex, like I do with all other layers.

The end goal is to be able to sort both WMS and geojson layers using setZIndex.

I am using leaflet 0.7.3

Thanks in advance!

Alexandru Pufan

unread,
Jan 26, 2015, 1:50:41 PM1/26/15
to leafl...@googlegroups.com
You could use, instead of setZIndex, bringToFront() and bringToBack()

Cosme Benito

unread,
Jan 26, 2015, 4:05:31 PM1/26/15
to leafl...@googlegroups.com
Hello Alexandru, thanks for your reply!

Unfortunately bringToFront/bringToBack() do not solve my problem because I will have more than 2 layers on the map. I wish the give the user the possibility to sort all layers, not just to bring one layer to the top.

Hopefully there is another way...

Cosme
Reply all
Reply to author
Forward
0 new messages