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)); },