From 43d9a488dfac2cde8b93d3a2400c8713c583a119 Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Mon, 22 May 2006 17:50:51 +0000 Subject: [PATCH] Cleanup the getZoomForExtent() code -- thanks to crschmidt for discovering that I had the ratio of max to current resolution flipped. git-svn-id: http://svn.openlayers.org/trunk/openlayers@270 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 708105fa69..920816d8bc 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -258,8 +258,10 @@ OpenLayers.Map.prototype = { */ getZoomForExtent: function (bounds) { var size = this.getSize(); - var deg_per_pixel = (bounds.getWidth() > bounds.getHeight() ? bounds.getWidth() / size.w : bounds.getHeight() / size.h); - var zoom = -( Math.log(deg_per_pixel / this.maxResolution) / Math.log(2) ); + var width = bounds.getWidth(); + var height = bounds.getHeight(); + var deg_per_pixel = (width > height ? width / size.w : height / size.h); + var zoom = Math.log(this.maxResolution / deg_per_pixel) / Math.log(2); return Math.floor(Math.max(zoom, 0)); },