From 145e446ceb243ccd546b22c8041438a6954a9ed7 Mon Sep 17 00:00:00 2001 From: euzuro Date: Wed, 3 Oct 2007 22:32:01 +0000 Subject: [PATCH] rearranging the style here for setBaseLayer() so that it's more readable, less duplication of code. No functional change, all tests pass git-svn-id: http://svn.openlayers.org/trunk/openlayers@4800 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index bd799f484a..4e9817dd6a 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -707,19 +707,21 @@ OpenLayers.Map = OpenLayers.Class({ //redraw all layers var center = this.getCenter(); if (center != null) { - if (oldExtent == null) { - // simply set center but force zoom change - this.setCenter( - center, - this.getZoomForResolution(this.resolution, true), - false, true - ); - } else { - // zoom to oldExtent *and* force zoom change - this.setCenter(oldExtent.getCenterLonLat(), - this.getZoomForExtent(oldExtent, true), - false, true); - } + + //either get the center from the old Extent or just from + // the current center of the map. + var newCenter = (oldExtent) + ? oldExtent.getCenterLonLat() + : center; + + //the new zoom will either come from the old Extent or + // from the current resolution of the map + var newZoom = (oldExtent) + ? this.getZoomForExtent(oldExtent, true) + : this.getZoomForResolution(this.resolution, true); + + // zoom and force zoom change + this.setCenter(newCenter, newZoom, false, true); } this.events.triggerEvent("changebaselayer");