allow google layer to be configured with min/max zoomLevels. update example.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1308 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -49,7 +49,10 @@ OpenLayers.Layer.Google.prototype =
|
||||
// OPTIONS
|
||||
|
||||
/** @type int */
|
||||
numZoomLevels: 16,
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
|
||||
|
||||
/**
|
||||
@@ -62,6 +65,8 @@ OpenLayers.Layer.Google.prototype =
|
||||
if (this.maxExtent == null) {
|
||||
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
}
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -263,6 +268,12 @@ OpenLayers.Layer.Google.prototype =
|
||||
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
|
||||
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
|
||||
var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
|
||||
zoom = this.getOLZoomFromGZoom(gZoom);
|
||||
}
|
||||
return zoom;
|
||||
@@ -291,7 +302,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
getOLZoomFromGZoom: function(gZoom) {
|
||||
var zoom = null;
|
||||
if (gZoom != null) {
|
||||
zoom = gZoom;
|
||||
zoom = gZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -306,7 +317,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
getGZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom;
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user