From 1d1452da618a41727a1ceb4e120dd5dd4f6e875a Mon Sep 17 00:00:00 2001 From: crschmidt Date: Mon, 29 May 2006 19:18:29 +0000 Subject: [PATCH] r439@creusa: crschmidt | 2006-05-29 13:32:54 -0400 Change Layer.js to call a moveTo function after visibility changes: This allows us to implement #56. Layer/Grid.js now has code which shows how to have a layer which doesn't load when it's not visible: This code will be dependant on the layers, so this has to be implemented per class. However, classes like markers suffer very little performance cost for drawing, so Layer.Grid is the most important place for this improvement. git-svn-id: http://svn.openlayers.org/trunk/openlayers@458 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer.js | 1 + lib/OpenLayers/Layer/Grid.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 70bbacd4d6..2aa119e4ce 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -58,6 +58,7 @@ OpenLayers.Layer.prototype = { */ setVisibility: function(visible) { this.div.style.display = (visible) ? "block" : "none"; + this.moveTo(this.map.getExtent()); }, /** @final @type String */ diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 13b55977ba..60e69de455 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -47,6 +47,12 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), { * @param {OpenLayers.Bounds} */ moveTo:function(bounds,zoomChanged) { + if (!this.getVisibility()) { + if (zoomChanged) { + this.grid = null; + } + return; + } if (!this.grid || zoomChanged) { this._initTiles(); } else {