When we remove a layer from the map, if it is the base Layer, we need to find *another* base layer to replace it, otherwise when we call getExtent, etc. it will be on the *old* base layer, which no longer has a map object defined.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@999 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -327,6 +327,15 @@ OpenLayers.Map.prototype = {
|
|||||||
this.layerContainerDiv.removeChild(layer.div);
|
this.layerContainerDiv.removeChild(layer.div);
|
||||||
}
|
}
|
||||||
this.layers.remove(layer);
|
this.layers.remove(layer);
|
||||||
|
if (this.baseLayer == layer) {
|
||||||
|
this.baseLayer = null;
|
||||||
|
for(i=0; i < this.layers.length; i++) {
|
||||||
|
if ( (this.baseLayer == null) && (this.layers[i].isBaseLayer()) ) {
|
||||||
|
this.baseLayer = this.layers[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
layer.map = null;
|
layer.map = null;
|
||||||
this.events.triggerEvent("removelayer");
|
this.events.triggerEvent("removelayer");
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user