L.geoJson.setZIndex doesn't seem to work
See original GitHub issueTrying to control layer order with L.geoJson
but it seems that map.addLayer(layer)
always adds the layer on top, if the layer was created with L.geoJson
.
I’ve tried layer.setZIndex(foo)
and this doesn’t affect it, and also creating the layer with L.geoJson(data, {zIndex: foo})
.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to set the zIndex layer order for geoJson layers?
I would like to set the zIndex dynamically based on properties. Leaflet has the method setZIndex() , but this apparently does not work...
Read more >how do I set zindex for geojson layers? - Google Groups
I know bringtofront, but working with 3 polyline layers, what should I do? thanks. L.
Read more >GeoJSON Layer Order In Leaflet 0.7.5 - GIS Stack Exchange
This also means that yes, setZIndex does not work on GeoJSON layers (only tile layers). You need to think of a workaround that...
Read more >Documentation - a JavaScript library for interactive maps
Note that, if your page doesn't use HTTPS, this method will fail in modern ... Returns a GeoJSON representation of the marker (as...
Read more >[FEATURE-723] Perspective map GeoJSON doesn't accept style
The JeoJSON is very light and use a lot in ArcGIS API response, so it is much faster to consume it in leaflet....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@neothemachine I would go for a warning instead of exceptions. Since
L.geojson
inherits fromL.LayerGroup
, andL.layerGroup
hassetZIndex
, it’s not unreasonable for user to expect that callingsetZIndex
on any object that inherits fromL.layerGroup
will not throw an error.As for sort layers, I would love to have that. It would be nice to have a way to disable that functionality (like
setZIndex
tonull
) so that maps with many geojson layers do not pay the cost of sorting them if the user don’t care about their order.I just stumbled over the same issue in 1.0rc1 and found it very confusing. If setZIndex has no effect in a geojson layer then it should throw an exception as it is clearly a programmer error. Of course, it would be nice to actually get setZIndex working since it is possible to sort layers with the bringToBack and bringToFront methods. Can’t the geoJson (or other suitable) class not override setZIndex and implement such logic?