add Map createPane/getPane methods, close #1742

This commit is contained in:
Vladimir Agafonkin 2013-12-30 19:17:52 +02:00
parent dd1b9617dd
commit 76f9c7ae7f
3 changed files with 22 additions and 24 deletions

9
dist/leaflet.css vendored
View File

@ -1,15 +1,10 @@
/* required styles */
.leaflet-map-pane,
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-pane,
.leaflet-tile-container,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
.leaflet-marker-pane,
.leaflet-popup-pane,
.leaflet-map-pane svg,
.leaflet-map-pane canvas,
.leaflet-zoom-box,
@ -61,6 +56,8 @@
-moz-user-select: none;
}
.leaflet-pane { z-index: 4; }
.leaflet-tile-pane { z-index: 2; }
.leaflet-overlay-pane { z-index: 4; }
.leaflet-shadow-pane { z-index: 5; }

View File

@ -77,9 +77,7 @@ L.Layer = L.Evented.extend({
},
getPane: function (name) {
// TODO make pane if not present
var paneName = name ? (this.options[name] || name) : this.options.pane;
return this._map._panes[paneName];
return this._map.getPane(name ? (this.options[name] || name) : this.options.pane);
}
});

View File

@ -229,6 +229,12 @@ L.Map = L.Evented.extend({
return this;
},
createPane: function (name, container) {
var className = 'leaflet-pane leaflet-' + name + '-pane';
var pane = this._panes[name + 'Pane'] = L.DomUtil.create('div', className, container || this._mapPane);
return pane;
},
// public methods for getting map state
@ -317,6 +323,10 @@ L.Map = L.Evented.extend({
return this.options.crs.getProjectedBounds(this.getZoom());
},
getPane: function (pane) {
return typeof pane === 'string' ? this._panes[pane] : pane;
},
getPanes: function () {
return this._panes;
},
@ -435,27 +445,20 @@ L.Map = L.Evented.extend({
_initPanes: function () {
var panes = this._panes = {};
this._mapPane = panes.mapPane = this._createPane('leaflet-map-pane', this._container);
this._mapPane = this.createPane('map', this._container);
panes.tilePane = this._createPane('leaflet-tile-pane');
panes.shadowPane = this._createPane('leaflet-shadow-pane');
panes.overlayPane = this._createPane('leaflet-overlay-pane');
panes.markerPane = this._createPane('leaflet-marker-pane');
panes.popupPane = this._createPane('leaflet-popup-pane');
var zoomHide = ' leaflet-zoom-hide';
this.createPane('tile');
this.createPane('shadow');
this.createPane('overlay');
this.createPane('marker');
this.createPane('popup');
if (!this.options.markerZoomAnimation) {
L.DomUtil.addClass(panes.markerPane, zoomHide);
L.DomUtil.addClass(panes.shadowPane, zoomHide);
L.DomUtil.addClass(panes.popupPane, zoomHide);
L.DomUtil.addClass(panes.markerPane, 'leaflet-zoom-hide');
L.DomUtil.addClass(panes.shadowPane, 'leaflet-zoom-hide');
}
},
_createPane: function (className, container) {
return L.DomUtil.create('div', className, container || this._mapPane);
},
// private methods that modify map state