From 9984c776de9d78d2b793010500668f8cf0b6caea Mon Sep 17 00:00:00 2001 From: crschmidt Date: Tue, 15 Aug 2006 02:15:03 +0000 Subject: [PATCH] Since VirtualEarth doesn't understand bounds at all, this function didn't work. This is not an ideal situation, becauuse it's not really 100% correct for a mercator projection, but it does cause things to work. It seems that for some reason, the EventPane isn't actually catching all the move events -- this seems to be what is causing the slow dragging. I'm not sure of the reason for this, but maybe Erik or someone else will be able to offer hints. I could also just be wrong ;) I just know it's slow, really. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1208 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/VirtualEarth.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Layer/VirtualEarth.js b/lib/OpenLayers/Layer/VirtualEarth.js index ea2fc6ec04..f256d6e04d 100644 --- a/lib/OpenLayers/Layer/VirtualEarth.js +++ b/lib/OpenLayers/Layer/VirtualEarth.js @@ -212,12 +212,25 @@ OpenLayers.Layer.VirtualEarth.prototype = * @type int */ getZoomForExtent: function (bounds) { - var zoom = null; - if (this.vemap != null) { - var gBounds = this.getVELatLongBoundsFromOLBounds(bounds); - var gZoom = this.vemap.getBoundsZoomLevel(gBounds); - zoom = this.getOLZoomFromGZoom(gZoom); - } + + 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) ); + + var maxZoomLevel = this.map.getMaxZoomLevel(); + var minZoomLevel = this.map.getMinZoomLevel(); + + //make sure zoom is within bounds + zoom = Math.min( Math.max(zoom, minZoomLevel), + maxZoomLevel ); + return zoom; },