bluehalo / ngx-leaflet

Core Leaflet package for Angular.io
MIT License
774 stars 127 forks source link

Invert the layer rendering on map #309

Closed shobanmr closed 2 years ago

shobanmr commented 3 years ago

I'm using the ngx-leaflet package for map in angular application. I have configured some layers in geoserver and applied those layers in the map. Example Layers:

Current Pending Historic While rendering these layers in map. At first it renders Current layer and it renders Pending on top of Current and Historic is renders on top of Pending.

Can it be reversed ?

I mean the Historic needs to be at the bottom and then Pending on top of Historic and Current layer on top of Pending.

reblace commented 2 years ago

The order the layers are added in depends on the approach you're taking. Generally, they will be added in ascending z-order according to the order they are in the layers array or the order they appear in the DOM. So, the first one in the list will actually be the bottom layer with the others stacking on top (as you mention).

You can simply reverse the order of your layers list. Or, you can use a LayerGroup or FeatureGroup to set the order explicitly and then add the group using [leafletLayer].

If you need more detail than this, you should put a code example on stackoverflow.