diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index c61e7e8408..a5d38b932f 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -24,6 +24,7 @@ OpenLayers.Layer.Grid.prototype = * @type boolean */ alpha: false, + /** * @constructor * @@ -196,90 +197,6 @@ OpenLayers.Layer.Grid.prototype = }, - /** - * @param {Boolean} prepend if true, prepend to beginning. - * if false, then append to end - */ - insertRow:function(prepend) { - var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1); - var modelRow = this.grid[modelRowIndex]; - - var newRow = new Array(); - - var resolution = this.map.getResolution(); - var deltaY = (prepend) ? -this.tileSize.h : this.tileSize.h; - var deltaLat = resolution * -deltaY; - - for (var i=0; i < modelRow.length; i++) { - var modelTile = modelRow[i]; - var bounds = modelTile.bounds.copyOf(); - var position = modelTile.position.copyOf(); - bounds.bottom = bounds.bottom + deltaLat; - bounds.top = bounds.top + deltaLat; - position.y = position.y + deltaY; - var newTile = this.addTile(bounds, position); - newTile.draw(this.alpha); - newRow.append(newTile); - } - - if (newRow.length>0){ - if (prepend) { - this.grid.prepend(newRow); - } else { - this.grid.append(newRow); - } - } - }, - - /** - * @param {Boolean} prepend if true, prepend to beginning. - * if false, then append to end - */ - insertColumn:function(prepend) { - var modelCellIndex; - var deltaX = (prepend) ? -this.tileSize.w : this.tileSize.w; - var resolution = this.map.getResolution(); - var deltaLon = resolution * deltaX; - - for (var i=0; i 0) { - var row = this.grid[0]; - while(row.length > 0) { - var tile = row[0]; - tile.destroy(); - row.remove(tile); - } - this.grid.remove(row); - } - } - }, /** * addTile gives subclasses of Grid the opportunity to create an @@ -296,6 +213,12 @@ OpenLayers.Layer.Grid.prototype = }, + /********************************************************/ + /* */ + /* Baselayer Functions */ + /* */ + /********************************************************/ + /** * @returns Degrees per Pixel * @type float @@ -335,6 +258,95 @@ OpenLayers.Layer.Grid.prototype = return zoom; }, + /** go through and remove all tiles from the grid, calling + * destroy() on each of them to kill circular references + * + * @private + */ + clearGrid:function() { + if (this.grid) { + while(this.grid.length > 0) { + var row = this.grid[0]; + while(row.length > 0) { + var tile = row[0]; + tile.destroy(); + row.remove(tile); + } + this.grid.remove(row); + } + } + }, + + /** + * @private + * + * @param {Boolean} prepend if true, prepend to beginning. + * if false, then append to end + */ + insertRow:function(prepend) { + var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1); + var modelRow = this.grid[modelRowIndex]; + + var newRow = new Array(); + + var resolution = this.map.getResolution(); + var deltaY = (prepend) ? -this.tileSize.h : this.tileSize.h; + var deltaLat = resolution * -deltaY; + + for (var i=0; i < modelRow.length; i++) { + var modelTile = modelRow[i]; + var bounds = modelTile.bounds.copyOf(); + var position = modelTile.position.copyOf(); + bounds.bottom = bounds.bottom + deltaLat; + bounds.top = bounds.top + deltaLat; + position.y = position.y + deltaY; + var newTile = this.addTile(bounds, position); + newTile.draw(this.alpha); + newRow.append(newTile); + } + + if (newRow.length>0){ + if (prepend) { + this.grid.prepend(newRow); + } else { + this.grid.append(newRow); + } + } + }, + + /** + * @private + * + * @param {Boolean} prepend if true, prepend to beginning. + * if false, then append to end + */ + insertColumn:function(prepend) { + var modelCellIndex; + var deltaX = (prepend) ? -this.tileSize.w : this.tileSize.w; + var resolution = this.map.getResolution(); + var deltaLon = resolution * deltaX; + + for (var i=0; i