diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index a977ab69f6..e463898b69 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -194,10 +194,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { _addZoomBar:function(centered) { var imgLocation = OpenLayers.Util.getImageLocation("slider.png"); var id = this.id + "_" + this.map.id; - var minZoom = 0; - if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) { - minZoom = this.map.adjustZoom(0); - } + var minZoom = this.map.getMinZoom(); var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom(); var slider = OpenLayers.Util.createAlphaImageDiv(id, centered.add(-1, zoomsToEnd * this.zoomStopHeight), diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index c125f27f5e..ab2cc1a928 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1786,18 +1786,42 @@ OpenLayers.Map = OpenLayers.Class({ * 's maxExtent. */ adjustZoom: function(zoom) { - var resolution, resolutions = this.baseLayer.resolutions, - maxResolution = this.getMaxExtent().getWidth() / this.size.w; - if (this.getResolutionForZoom(zoom) > maxResolution) { - for (var i=zoom|0, ii=resolutions.length; i maxResolution) { + if (this.fractionalZoom) { + zoom = this.getZoomForResolution(maxResolution); + } else { + for (var i=zoom|0, ii=resolutions.length; i set to true, this will be the + * first zoom level that shows no more than one world width in the current + * map viewport. Components that rely on this value (e.g. zoom sliders) + * should also listen to the map's "updatesize" event and call this method + * in the "updatesize" listener. + * + * Returns: + * {Number} Minimum zoom level that shows a map not wider than its + * 's maxExtent. This is an Integer value, unless the map is + * configured with set to true. + */ + getMinZoom: function() { + return this.adjustZoom(0); + }, /** * Method: moveTo @@ -1820,13 +1844,11 @@ OpenLayers.Map = OpenLayers.Class({ zoom = Math.round(zoom); } } - if (this.baseLayer.wrapDateLine) { - var requestedZoom = zoom; - zoom = this.adjustZoom(zoom); - if (zoom !== requestedZoom) { - // zoom was adjusted, so keep old lonlat to avoid panning - lonlat = this.getCenter(); - } + var requestedZoom = zoom; + zoom = this.adjustZoom(zoom); + if (zoom !== requestedZoom) { + // zoom was adjusted, so keep old lonlat to avoid panning + lonlat = this.getCenter(); } // dragging is false by default var dragging = options.dragging || this.dragging;