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:
@@ -431,16 +431,19 @@ OpenLayers.Map.prototype = {
|
||||
* @param {Boolean} 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?
|
||||
if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {
|
||||
|
||||
// make the old base layer invisible
|
||||
if (oldBaseLayer != null) {
|
||||
oldBaseLayer.setVisibility(false, noEvent);
|
||||
if (this.baseLayer != null) {
|
||||
this.baseLayer.setVisibility(false, noEvent);
|
||||
}
|
||||
|
||||
// set new baselayer and make it visible
|
||||
@@ -450,10 +453,10 @@ OpenLayers.Map.prototype = {
|
||||
//redraw all layers
|
||||
var center = this.getCenter();
|
||||
if (center != null) {
|
||||
if (oldBaseLayer == null) {
|
||||
if (oldExtent == null) {
|
||||
this.setCenter(center);
|
||||
} else {
|
||||
this.zoomToExtent(oldBaseLayer.getExtent());
|
||||
this.zoomToExtent(oldExtent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user