track old extent when changing base layers - see #463

git-svn-id: http://svn.openlayers.org/trunk/openlayers@2167 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-01-20 17:03:40 +00:00
parent 7518b9716c
commit a64b91de7c

View File

@@ -431,16 +431,19 @@ OpenLayers.Map.prototype = {
* @param {Boolean} noEvent * @param {Boolean} noEvent
*/ */
setBaseLayer: function(newBaseLayer, noEvent) { setBaseLayer: function(newBaseLayer, noEvent) {
var oldBaseLayer = this.baseLayer; var oldExtent = null;
if(this.baseLayer) {
oldExtent = this.baseLayer.getExtent();
}
if (newBaseLayer != oldBaseLayer) { if (newBaseLayer != this.baseLayer) {
// is newBaseLayer an already loaded layer? // is newBaseLayer an already loaded layer?
if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) { if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
// make the old base layer invisible // make the old base layer invisible
if (oldBaseLayer != null) { if (this.baseLayer != null) {
oldBaseLayer.setVisibility(false, noEvent); this.baseLayer.setVisibility(false, noEvent);
} }
// set new baselayer and make it visible // set new baselayer and make it visible
@@ -450,10 +453,10 @@ OpenLayers.Map.prototype = {
//redraw all layers //redraw all layers
var center = this.getCenter(); var center = this.getCenter();
if (center != null) { if (center != null) {
if (oldBaseLayer == null) { if (oldExtent == null) {
this.setCenter(center); this.setCenter(center);
} else { } else {
this.zoomToExtent(oldBaseLayer.getExtent()); this.zoomToExtent(oldExtent);
} }
} }