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
This commit is contained in:
euzuro
2007-10-03 22:32:01 +00:00
parent 5904d15680
commit 145e446ceb

View File

@@ -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");