[OpenLayers-Commits] r4800 - trunk/openlayers/lib/OpenLayers

commits at openlayers.org commits at openlayers.org
Wed Oct 3 18:32:05 EDT 2007


Author: euzuro
Date: 2007-10-03 18:32:01 -0400 (Wed, 03 Oct 2007)
New Revision: 4800

Modified:
   trunk/openlayers/lib/OpenLayers/Map.js
Log:
rearranging the style here for setBaseLayer() so that it's more readable, less duplication of code. No functional change, all tests pass

Modified: trunk/openlayers/lib/OpenLayers/Map.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Map.js	2007-10-03 21:47:20 UTC (rev 4799)
+++ trunk/openlayers/lib/OpenLayers/Map.js	2007-10-03 22:32:01 UTC (rev 4800)
@@ -707,19 +707,21 @@
                 //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");



More information about the Commits mailing list