I'm having problems about the layer ordering in leaflet. I've followed this page http://leafletjs.com/examples/layers-control.html
exact question would be... how can I reorder the layers (foreground background etc).
Lets say, one of my "base layers" is made of semi transparent tiles, and I want to see the "overlay layers" through my base layer (it should be at the foreground)
Depending on the page example, here is a snippet to explain more about the issue:
var baseMaps = {
"Minimal": minimal,
"Night View": midnight,
"My Custom Layer": customlayer
};
var overlayMaps = {
"Motorways": motorways,
"Cities": cities
};
In other words, I would like to know how to set "My Custom Layer" as the layer that will be at the foreground (above overlayMaps).
I've tried setting zindex values of layers, didn't help.
Thanks.
The layers control has two sets of layers, the set of base layers and the set of overlay layers. The overlay layers will be drawn on top of the base layers. So generally, you'll want to add your transparent layer to the overlay layers.
The autoZIndex
option, which is by default On, specifies that the control must assign z indices to each of its layers in the order in which they are added, and that means they'll be drawn in that order.
See http://leafletjs.com/reference.html#control-layers
Sets the zIndex of the tile layer.
setZIndex( <Number> zIndex )
myLayer1.setZIndex(4);
myLayer2.setZIndex(5);
Layer 2 over Layer 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With