question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

L.geoJson.setZIndex doesn't seem to work

See original GitHub issue

Trying 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:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
SuberFucommented, Jun 8, 2016

@neothemachine I would go for a warning instead of exceptions. Since L.geojson inherits from L.LayerGroup, and L.layerGroup has setZIndex, it’s not unreasonable for user to expect that calling setZIndex on any object that inherits from L.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 to null) so that maps with many geojson layers do not pay the cost of sorting them if the user don’t care about their order.

0reactions
letmaikcommented, Jun 8, 2016

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?

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found