From 15d3d9fc21b0e7bbdd144d1b8ddeb54e7f601501 Mon Sep 17 00:00:00 2001 From: euzuro Date: Wed, 16 Aug 2006 15:53:33 +0000 Subject: [PATCH] do not update invisible baselayers as the user navigates around. only update them when they are made visible. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1239 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 7cdeba2462..fb78f23cad 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -358,23 +358,31 @@ OpenLayers.Map.prototype = { // is newBaseLayer an already loaded layer? var foundLayer = (this.layers.indexOf(newBaseLayer) != -1); - if (foundLayer) { - + + var oldExtent = null; + // make the old base layer invisible if (this.baseLayer != null) { + oldExtent = this.baseLayer.getExtent(); this.baseLayer.setVisibility(false, noEvent); } - - // set new baselayer + + // set new baselayer and move it to the old layer's extent this.baseLayer = newBaseLayer; - - // make the new one visible + if (oldExtent != null) { + this.baseLayer.moveTo(oldExtent); + } + + // make the new baselayer visible this.baseLayer.setVisibility(true, noEvent); - // now go back and reproject + // now go back and reproject the overlays for(var i=0; i < this.layers.length; i++) { - this.layers[i].reproject(); + var layer = this.layers[i]; + if (!layer.isBaseLayer) { + layer.reproject(); + } } if ((noEvent == null) || (noEvent == false)) { @@ -599,10 +607,13 @@ OpenLayers.Map.prototype = { } } - //send the move call to all the layers + //send the move call to the baselayer and all the overlays var bounds = this.getExtent(); for (var i = 0; i < this.layers.length; i++) { - this.layers[i].moveTo(bounds, zoomChanged, minor); + var layer = this.layers[i]; + if ((layer == this.baseLayer) || !layer.isBaseLayer) { + layer.moveTo(bounds, zoomChanged, minor); + } } this.events.triggerEvent("move");