From 221967cc3f66175bf374b12f156edb39052c7914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Sun, 27 Jan 2008 22:59:31 +0000 Subject: [PATCH] Map.setCenter() should not call Layer.moveTo if inRange has changed to false. With this patch you should no longer see tiles loading if your layer is out of range or not visible. Hopefully! r=crschmidt (closes #937) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5913 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/WFS.js | 3 +-- lib/OpenLayers/Map.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index d2ed9caba1..b6e2e88b9f 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -244,8 +244,7 @@ OpenLayers.Layer.WFS = OpenLayers.Class( var outOfBounds = (!firstRendering && !this.tile.bounds.containsBounds(bounds)); - if ( (zoomChanged || firstRendering || (!dragging && outOfBounds)) - && this.inRange) { + if (zoomChanged || firstRendering || (!dragging && outOfBounds)) { //determine new tile bounds var center = bounds.getCenterLonLat(); var tileWidth = bounds.getWidth() * this.ratio; diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 1f1b949676..40dabc4a10 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1341,23 +1341,19 @@ OpenLayers.Map = OpenLayers.Class({ for (var i = 0; i < this.layers.length; i++) { var layer = this.layers[i]; if (!layer.isBaseLayer) { - - var moveLayer; var inRange = layer.calculateInRange(); if (layer.inRange != inRange) { - // Layer property has changed. We are going - // to call moveLayer so that the layer can be turned - // off or on. + // the inRange property has changed. If the layer is + // no longer in range, we turn it off right away. If + // the layer is no longer out of range, the moveTo + // call below will turn on the layer. layer.inRange = inRange; - moveLayer = true; + if (!inRange) { + layer.display(false); + } this.events.triggerEvent("changelayer"); - } else { - // If nothing has changed, then we only move the layer - // if it is visible and inrange. - moveLayer = (layer.visibility && layer.inRange); } - - if (moveLayer) { + if (inRange && layer.visibility) { layer.moveTo(bounds, zoomChanged, dragging); } }