Add zIndex support to L.TileLayer

This commit is contained in:
Matt Currie
2012-07-27 14:12:40 +12:00
parent 6965ad6729
commit 6142a8b74c
2 changed files with 18 additions and 1 deletions

3
dist/leaflet.css vendored
View File

@ -11,7 +11,8 @@
.leaflet-popup-pane,
.leaflet-overlay-pane svg,
.leaflet-zoom-box,
.leaflet-image-layer { /* TODO optimize classes */
.leaflet-image-layer,
.leaflet-layer { /* TODO optimize classes */
position: absolute;
}
.leaflet-container {

View File

@ -12,6 +12,7 @@ L.TileLayer = L.Class.extend({
subdomains: 'abc',
errorTileUrl: '',
attribution: '',
zIndex: 0,
opacity: 1,
tms: false,
continuousWorld: false,
@ -124,6 +125,13 @@ L.TileLayer = L.Class.extend({
return this;
},
setZIndex: function (zIndex) {
this.options.zIndex = zIndex;
this._updateZIndex();
return this;
},
setUrl: function (url, noRedraw) {
this._url = url;
@ -143,6 +151,12 @@ L.TileLayer = L.Class.extend({
return this;
},
_updateZIndex: function () {
if (this._container) {
this._container.style.zIndex = this.options.zIndex;
}
},
_updateOpacity: function () {
L.DomUtil.setOpacity(this._container, this.options.opacity);
@ -166,6 +180,8 @@ L.TileLayer = L.Class.extend({
if (!this._container || tilePane.empty) {
this._container = L.DomUtil.create('div', 'leaflet-layer');
this._updateZIndex();
if (this._insertAtTheBottom && first) {
tilePane.insertBefore(this._container, first);
} else {