just like r1308, we update virtual earth to use min/max zoomlevel, and update the example
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1309 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -15,7 +15,10 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
vemap: null,
|
||||
|
||||
/** @type int */
|
||||
numZoomLevels: 17,
|
||||
minZoomLevel: 1,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 17,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -24,6 +27,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
*/
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -203,21 +208,26 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, 0),
|
||||
this.numZoomLevels-1);
|
||||
|
||||
var zoom = null;
|
||||
if (this.vemap != null) {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromVEZoom(veZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -245,7 +255,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
getOLZoomFromVEZoom: function(veZoom) {
|
||||
var zoom = null;
|
||||
if (veZoom != null) {
|
||||
zoom = veZoom;
|
||||
zoom = veZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -260,7 +270,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
getVEZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom;
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user