From 80f13188a3854217c7143adfffce1aadeac16fb7 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 7 Jan 2013 14:26:41 +0100 Subject: [PATCH] Addressing @bartvde's review comments --- lib/OpenLayers/Layer/Grid.js | 2 +- lib/OpenLayers/Tile.js | 7 +++++-- lib/OpenLayers/Tile/Image.js | 4 ++-- lib/OpenLayers/TileManager.js | 21 ++++++++++++++++----- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 67af6528c0..3a0cbb6e73 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -377,7 +377,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { // we do not want to copy reference to grid, so we make a new array obj.grid = []; obj.gridResolution = null; - // same for backbuffer and tile queue + // same for backbuffer obj.backBuffer = null; obj.backBufferTimerId = null; obj.loading = false; diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index 10f754bb4e..f36204892e 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -193,10 +193,13 @@ OpenLayers.Tile = OpenLayers.Class({ * is to call and return the result from . * * Parameters: - * force - {Boolean} No beforedraw event will be fired. + * force - {Boolean} If true, the tile will not be cleared and no beforedraw + * event will be fired. This is used for drawing tiles asynchronously + * after drawing has been cancelled by returning false from a beforedraw + * listener. * * Returns: - * {Boolean} Whether or not the tile should actually be drawn. Retruns null + * {Boolean} Whether or not the tile should actually be drawn. Returns null * if a beforedraw listener returned false. */ draw: function(force) { diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index fb0ccb6737..0d2ecba964 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -298,10 +298,10 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { /** * APIMethod: setImage - * Sets the image element or this tile. This method should only be called + * Sets the image element for this tile. This method should only be called * from beforeload listeners. * - * Paramters + * Parameters * img - {HTMLImageElement} The image to use for this tile. */ setImage: function(img) { diff --git a/lib/OpenLayers/TileManager.js b/lib/OpenLayers/TileManager.js index bbf04a1021..31dc12a5a3 100644 --- a/lib/OpenLayers/TileManager.js +++ b/lib/OpenLayers/TileManager.js @@ -17,7 +17,7 @@ * * Queueing avoids unnecessary image requests while changing zoom levels * quickly, and helps improve dragging performance on mobile devices that show - * a lag in dragging when loading of new images start. and + * a lag in dragging when loading of new images starts. and * are the configuration options to control this behavior. * * Caching avoids setting the src on image elements for images that have already @@ -74,8 +74,8 @@ OpenLayers.TileManager = OpenLayers.Class({ /** * Property: tileCacheIndex - * {Array} URLs of cached tiles. First entry in each array is the - * least recently used. + * {Array(String)} URLs of cached tiles. First entry is the least recently + * used. */ tileCacheIndex: null, @@ -120,6 +120,13 @@ OpenLayers.TileManager = OpenLayers.Class({ }); }, + /** + * Method: removeMap + * Unbinds this instance from a map + * + * Parameters: + * map - {} + */ removeMap: function(map) { if (this._destroyed) { return; @@ -141,6 +148,7 @@ OpenLayers.TileManager = OpenLayers.Class({ } delete this.tileQueue[map.id]; delete this.tileQueueId[map.id]; + OpenLayers.Util.removeItem(this.maps, map); }, /** @@ -321,7 +329,7 @@ OpenLayers.TileManager = OpenLayers.Class({ * Adds, updates, removes and fetches cache entries. * * Parameters: - * evt - {Object} Listener argument of the tile's loadstart event + * evt - {Object} Listener argument of the tile's beforeload event */ manageTileCache: function(evt) { var tile = evt.object; @@ -370,12 +378,15 @@ OpenLayers.TileManager = OpenLayers.Class({ var layer = evt.object; var tileQueue = this.tileQueue[layer.map.id]; for (var i=tileQueue.length-1; i>=0; --i) { - if (tileQueue.layer === layer) { + if (tileQueue[i].layer === layer) { tileQueue.splice(i, 1); } } }, + /** + * Method: destroy + */ destroy: function() { for (var i=this.maps.length-1; i>=0; --i) { this.removeMap(this.maps[i]);