From 96c3720aab00ef0359e5a3a039464c7d6f0910ea Mon Sep 17 00:00:00 2001 From: euzuro Date: Fri, 21 Jul 2006 18:22:37 +0000 Subject: [PATCH] protect for null bounds (not-loaded map) git-svn-id: http://svn.openlayers.org/trunk/openlayers@993 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer.js | 5 +++- lib/OpenLayers/Layer/Grid.js | 47 ++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 807500e061..7150822aa6 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -170,7 +170,10 @@ OpenLayers.Layer.prototype = { setVisibility: function(visible) { this.div.style.display = (visible) ? "block" : "none"; if ((visible) && (this.map != null)) { - this.moveTo(this.map.getExtent()); + var extent = this.map.getExtent(); + if (extent != null) { + this.moveTo(this.map.getExtent()); + } } }, diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 93e4206d8e..570510e973 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -135,28 +135,33 @@ OpenLayers.Layer.Grid.prototype = * @param {Boolean} minor */ moveTo:function(bounds, zoomChanged, minor) { - if (!this.getVisibility()) { - if (zoomChanged) { - //now clear out the old grid and start a new one - this.clearGrid(); - this.grid = null; - } - } else { - if (!this.grid || zoomChanged) { - this._initTiles(); - } else { - var i = 0; - while (this.getGridBounds().bottom > bounds.bottom) { - this.insertRow(false); + if (bounds == null) { + bounds = this.map.getBounds(); + } + if (bounds != null) { + if (!this.getVisibility()) { + if (zoomChanged) { + //now clear out the old grid and start a new one + this.clearGrid(); + this.grid = null; } - while (this.getGridBounds().left > bounds.left) { - this.insertColumn(true); - } - while (this.getGridBounds().top < bounds.top) { - this.insertRow(true); - } - while (this.getGridBounds().right < bounds.right) { - this.insertColumn(false); + } else { + if (!this.grid || zoomChanged) { + this._initTiles(); + } else { + var i = 0; + while (this.getGridBounds().bottom > bounds.bottom) { + this.insertRow(false); + } + while (this.getGridBounds().left > bounds.left) { + this.insertColumn(true); + } + while (this.getGridBounds().top < bounds.top) { + this.insertRow(true); + } + while (this.getGridBounds().right < bounds.right) { + this.insertColumn(false); + } } } }