Switching base layer hides overlay layer

22 views
Skip to first unread message

Linus Kamb

unread,
Apr 7, 2017, 6:31:04 PM4/7/17
to Leaflet
Hi all,

TL;DR:  Why would not including overlay layers in the Layer Control tool cause the overlay layer to become hidden underneath the base layer when the base layer is changed ?

I'm developing a leaflet-based app that went from a single map to a set of tabs of different but related maps that need to be kept somewhat in sync, such as showing the same overlay layers on all of them, so I have to trap click- and change events in order to process them across multiple maps.

Somewhere along the way of making all the changes to make that work, I discovered that when I switch base layers using the Layer Control tool, the overlay layer ends up underneath the base layer.  I know the overlay layer is still there, because when I switch base layers again, the overlay shows briefly while the base layer tiles are loaded.

I finally managed to track down the apparent change that made this happen was when I stopped including the overlay layers in the Layer Control tool(s).

And even stranger, it only happens with two of the three overlay layers.  One works fine whether or not it is added to the Layer Control.

I think it must certainly be something in my code, but the overlay layers are all (ostensibly) handled in the same way, so it's not at clear to me where to look.  I'm hoping someone can me some pointers where to narrow my debugging search.

Note that feature and point layers are not affected.

I am using  leaflet version 1.0.3+ed36a04

Hoping somebody can give me a clue,

Thanks,
- Linus

Linus Kamb

unread,
Apr 7, 2017, 7:49:04 PM4/7/17
to Leaflet
For what it's worth, I got around this by forcing all of my overlay layers to have a higher zIndex.

Seems hack-ish, but addresses the immediate problem.

I'd still like to know if anyone has any suggestions as to why the problem might occur.

thanks,
Linus
Reply all
Reply to author
Forward
0 new messages