Overlay below fragments in Leaflet.js

I have a Leaflet.js map, with a base tile layer, a tile layer and some overlays. I need to place a tile layer above the text ABOVE overlay. I tried to bring it to the end, using bringToFront()- to no avail. Here is the code:

map.addLayer( new L.StamenTileLayer("toner-lines") );
...// more code, loading the overlays, etc
var labels = L.tileLayer('http://{s}.www.toolserver.org/tiles/osm-labels-en/{z}/{x}/{y}.png', {
    maxZoom: 17,
    zIndex: 1000
});
labels.addTo(map);
labels.bringToFront();
+4
source share
1 answer

The problem is that Tile Layer entire stack runs under the entire stack Overlay Layer, and the team bringToFront, and sendToBackonly affect the layers within each respective stack. There is a bug report detailing this on the gitub Leaflet website. It can be fixed at 0.7, but it has already been dropped a couple of times.

jfirebaugh. , . DOM , , :

var topPane = map._createPane('leaflet-top-pane', map.getPanes().mapPane);
var topLayer = L.mapbox.tileLayer('lxbarth.map-vtt23b1i').addTo(map);
topPane.appendChild(topLayer.getContainer());
topLayer.setZIndex(9);
+4

All Articles