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
This commit is contained in:
euzuro
2006-08-16 15:53:33 +00:00
parent d828dd8f81
commit 15d3d9fc21
+21 -10
View File
@@ -358,23 +358,31 @@ OpenLayers.Map.prototype = {
// is newBaseLayer an already loaded layer? // is newBaseLayer an already loaded layer?
var foundLayer = (this.layers.indexOf(newBaseLayer) != -1); var foundLayer = (this.layers.indexOf(newBaseLayer) != -1);
if (foundLayer) { if (foundLayer) {
var oldExtent = null;
// make the old base layer invisible // make the old base layer invisible
if (this.baseLayer != null) { if (this.baseLayer != null) {
oldExtent = this.baseLayer.getExtent();
this.baseLayer.setVisibility(false, noEvent); this.baseLayer.setVisibility(false, noEvent);
} }
// set new baselayer // set new baselayer and move it to the old layer's extent
this.baseLayer = newBaseLayer; this.baseLayer = newBaseLayer;
if (oldExtent != null) {
// make the new one visible this.baseLayer.moveTo(oldExtent);
}
// make the new baselayer visible
this.baseLayer.setVisibility(true, noEvent); 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++) { 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)) { 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(); var bounds = this.getExtent();
for (var i = 0; i < this.layers.length; i++) { 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"); this.events.triggerEvent("move");