diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 9953738693..2d8d03caad 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -23,14 +23,12 @@ OpenLayers.Map.prototype = { // OpenLayers.Bounds maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90), - /* maxScale was determined empirically by finding the resolution - of GMaps in degrees per pixel at zoom level 0. */ - // float - maxResolution: .3515625, // degrees per pixel - /* projection */ projection: "EPSG:4326", + // float + maxResolution: null, // degrees per pixel + // DOMElement: the div that our map lives in div: null, @@ -78,7 +76,6 @@ OpenLayers.Map.prototype = { this.viewPortDiv.style.position = "relative"; this.div.appendChild(this.viewPortDiv); - // the layerContainerDiv is the one that holds all the layers this.layerContainerDiv = OpenLayers.Util.createDiv( div.id + "_OpenLayers_Container" ); @@ -87,6 +84,12 @@ OpenLayers.Map.prototype = { this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES); this.updateSize(); + // make the entire maxExtent fix in zoom level 0 by default + if (this.maxResolution == null) { + this.maxResolution = Math.max( + this.maxExtent.getWidth() / this.size.w, + this.maxExtent.getHeight() / this.size.h ); + } // update the internal size register whenever the div is resized this.events.register("resize", this, this.updateSize);