Control.Layers dont preserve layers order #5201

mrit64 opened this Issue Dec 17, 2016 · 2 comments


None yet

2 participants

mrit64 commented Dec 17, 2016 edited
  • Leaflet version I'm using: 1.0.2
  • Browser (with version) I'm using: Chrome & FF
  • OS/Platform (with version) I'm using: Windows 10

What behaviour I'm expecting and which behaviour I'm seeing

Documentation say about Control.Layers's autoZIndex option : If true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.

It's not working as expected : the order is NOT preserved when switching them on/off.

Minimal example reproducing the issue

@IvanSanchez IvanSanchez added this to the 1.1 milestone Dec 18, 2016

The problem here is that the autoZIndex option, as well as the setZIndex() method only affect GridLayers, and only those within the same map pane.

Read (if you haven't done so yet) the map panes tutorial for a workaround.

This (paired with the functionality that map panes provide) can make a case for making setZIndex obsolete. Right now I'm thinking about amending just the documentation to make it clear that autoZIndex only works for the order of GridLayers/TileLayers.

mrit64 commented Dec 18, 2016

OK, autoZIndex is not made for overlay layers. Thanks for the precision.
Clarifying the documentation could help, I agree.
I am using Panes. They work well in SVG layers, but I have difficulties with Canvas layers (see #5190). Another problem with Canvas layers and panes, is that you can treat mouse events only for the top layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment