calvinmetcalf / leaflet.shapefile

Shapefile in Leaflet
http://calvinmetcalf.github.io/leaflet.shapefile/
MIT License
259 stars 119 forks source link

Ordering different types of layers #34

Closed ismail44 closed 8 years ago

ismail44 commented 8 years ago

I am trying to set an "order" on the layers on my map. I have WMS, WFS, KML, and now (thanks to your awesome plugin) SHP. I am trying to set the "z-index" on this layer, however, it says that the method does not exist.

Is it possible for me to be able to sort the viewing of a SHP layer?

Basically, I want to be able to hide it behind say a KML at the same location.

Thanks.

calvinmetcalf commented 8 years ago

so behind the scenes all this plugin does is use shp.js to turn the shapefile into geojson and then load it as a geojson layer, so standard leaflet methods like bringToFront should be available depending on the leaflet version. One thing to bear in mind is that since things are loaded async even if you put the shapefile layer on the map before the kml one the kml may load first and thus be underneath the shapefile.

More generally any app where you know the data before hand you should strongly consider NOT using this plugin and convert the shpfile into geojson ahead of time

ismail44 commented 8 years ago

Thanks for the reply!

I've dug a bit deeper and I see that leaflet creates 2 divs... one for tile-type layers (WMS, Base Layers, etc) and one for "overlays" (KML, SHP, GeoJSON, etc). I can swap positioning between "same types", just not between base and overlays (as one would expect).

And yeah... I don't know where someone may try to add layers from... I offer them a box for a URL and they put it in (it's a semi-closed system).

On Thu, Apr 7, 2016 at 11:07 AM, Calvin Metcalf notifications@github.com wrote:

so behind the scenes all this plugin does is use shp.js to turn the shapefile into geojson and then load it as a geojson layer, so standard leaflet methods like bringToFront should be available depending on the leaflet version. One thing to bear in mind is that since things are loaded async even if you put the shapefile layer on the map before the kml one the kml may load first and thus be underneath the shapefile.

More generally any app where you know the data before hand you should strongly consider NOT using this plugin and convert the shpfile into geojson ahead of time

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/calvinmetcalf/leaflet.shapefile/issues/34#issuecomment-206944820

calvinmetcalf commented 8 years ago

yes in leaflet 0.7 there are 2 different 'panes' one for overlays one for base layers