new restrictedMinZoom property. r=bartvde (closes #3024)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11058 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-01-24 21:43:35 +00:00
parent 2f7a3e818a
commit a1c80ffb7e
4 changed files with 84 additions and 5 deletions

View File

@@ -274,6 +274,18 @@ OpenLayers.Layer = OpenLayers.Class({
* {Integer}
*/
numZoomLevels: null,
/**
* Property: restrictedMinZoom
* {Integer} Restriction of the minimum zoom level. This is used for layers
* that only use a subset of the resolutions in the <resolutions>
* array. This is independent of <numResolutions>, which always starts
* counting at zoom level 0. If restrictedMinZoom is e.g. set to 2,
* the first two zoom levels (0 and 1) will not be used by this layer.
* If the layer is a base layer, zooming to the map's maxExtent means
* setting the map's zoom to 2.
*/
restrictedMinZoom: 0,
/**
* APIProperty: minScale
@@ -740,7 +752,8 @@ OpenLayers.Layer = OpenLayers.Class({
} else {
if (this.map) {
var resolution = this.map.getResolution();
inRange = ( (resolution >= this.minResolution) &&
inRange = ( this.map.getZoom() >= this.restrictedMinZoom &&
(resolution >= this.minResolution) &&
(resolution <= this.maxResolution) );
}
}
@@ -1171,7 +1184,7 @@ OpenLayers.Layer = OpenLayers.Class({
}
zoom = Math.max(0, i-1);
}
return zoom;
return Math.max(this.restrictedMinZoom, zoom);
},
/**

View File

@@ -1800,8 +1800,8 @@ OpenLayers.Map = OpenLayers.Class({
* within the min/max range of zoom levels.
*/
isValidZoomLevel: function(zoomLevel) {
return ( (zoomLevel != null) &&
(zoomLevel >= 0) &&
return ( (zoomLevel != null) &&
(zoomLevel >= this.getRestrictedMinZoom()) &&
(zoomLevel < this.getNumZoomLevels()) );
},
@@ -1905,6 +1905,20 @@ OpenLayers.Map = OpenLayers.Class({
return maxExtent;
},
/**
* Method: getRestricteMinZoom
*
* Returns:
* {Integer} the minimum zoom level allowed for the current baseLayer.
*/
getRestrictedMinZoom: function() {
var minZoom = null;
if (this.baseLayer != null) {
minZoom = this.baseLayer.restrictedMinZoom;
}
return minZoom;
},
/**
* APIMethod: getNumZoomLevels
*