From 0b39d32031836af30078a5e21448f1f916c18523 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 14 Nov 2011 17:49:41 +0100 Subject: [PATCH] Don't let wrapDateLine maps be wider than one world width. --- lib/OpenLayers/Map.js | 27 +++++++++++++++++++++++++++ tests/Layer/WrapDateLine.html | 6 +++--- tests/Map.html | 17 +++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 33daa3a66c..20bc652465 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1701,6 +1701,30 @@ OpenLayers.Map = OpenLayers.Class({ this.events.triggerEvent("move"); } }, + + /** + * Method: adjustZoom + * + * Parameters: + * zoom - {Number} The zoom level to adjust + * + * Returns: + * {Integer} Adjusted zoom level that shows a map not wider than its + * 's maxExtent. + */ + adjustZoom: function(zoom) { + var resolution, resolutions = this.baseLayer.resolutions, + maxResolution = this.getMaxExtent().getWidth() / this.getSize().w; + if (this.getResolutionForZoom(zoom) > maxResolution) { + for (var i=zoom|0, ii=resolutions.length; i