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 {