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.
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.
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.