Cannot perform vector geometry.
zIndex is a property of HTMLElement s, and vector geometries (lines and polygons) are displayed as SVG elements or programmatically as <canvas> drawing calls. These two methods have no zIndex concept, so the only thing that works is to push elements at the top (or bottom) of the SVG or <canvas> sequence.
Also, recall that L.GeoJSON is just a specific type of L.LayerGroup , in your case containing L.Polygon instances. Also, if you read the documentation about the setZIndex() method on L.LayerGroup :
Calls setZIndex on each layer contained in this group, passing z-index.
So do L.Polygon have a setZIndex() method? No. So call it in their containing group to do nothing. This will affect any L.GridLayer contained in this group.
Returning to your problem:
I would like certain layers to always be on top of the others, no matter in what order they are added to the map.
It looks like what you are looking for are cards. Read the card tutorial .
source share