From 5eb1fdfaca553cbadc1b97cda31f95599befaec5 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Mon, 24 Jul 2006 12:17:48 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Map.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 1a834b6a4f..290a1166d7 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -327,6 +327,15 @@ OpenLayers.Map.prototype = { this.layerContainerDiv.removeChild(layer.div); } 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; this.events.triggerEvent("removelayer"); },