[OpenLayers-Commits] r3628 - sandbox/euzuro/untiled3/lib/OpenLayers/Layer
commits at openlayers.org
commits at openlayers.org
Fri Jul 6 16:15:43 EDT 2007
Author: euzuro
Date: 2007-07-06 16:15:42 -0400 (Fri, 06 Jul 2007)
New Revision: 3628
Modified:
sandbox/euzuro/untiled3/lib/OpenLayers/Layer/Grid.js
Log:
add function to remove hooks from tiles
Modified: sandbox/euzuro/untiled3/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/euzuro/untiled3/lib/OpenLayers/Layer/Grid.js 2007-07-06 20:13:44 UTC (rev 3627)
+++ sandbox/euzuro/untiled3/lib/OpenLayers/Layer/Grid.js 2007-07-06 20:15:42 UTC (rev 3628)
@@ -86,7 +86,9 @@
for(var iRow=0; iRow < this.grid.length; iRow++) {
var row = this.grid[iRow];
for(var iCol=0; iCol < row.length; iCol++) {
- row[iCol].destroy();
+ var tile = row[iCol];
+ this.removeTileMonitoringHooks(tile);
+ tile.destroy();
}
}
this.grid = [];
@@ -276,33 +278,41 @@
*/
addTileMonitoringHooks: function(tile) {
- var onLoadStart = function() {
-
- //if there are no tiles loading then trigger a 'loadstart'
- // event on the layer
+ tile.onLoadStart = function() {
+ //if that was first tile then trigger a 'loadstart' on the layer
if (this.numLoadingTiles == 0) {
this.events.triggerEvent("loadstart");
}
this.numLoadingTiles++;
-
};
- tile.events.register("loadstart",
- this,
- onLoadStart.bindAsEventListener(this));
+ tile.events.register("loadstart", this, tile.onLoadStart);
- var onLoadEnd = function() {
+ tile.onLoadEnd = function() {
this.numLoadingTiles--;
+ //if that was the last tile, then trigger a 'loadend' on the layer
if (this.numLoadingTiles == 0) {
this.events.triggerEvent("loadend");
}
};
- tile.events.register("loadend",
- this,
- onLoadEnd.bindAsEventListener(this));
+ tile.events.register("loadend", this, tile.onLoadEnd);
},
-
+
+
+ /**
+ * Method: removeTileMonitoringHooks
+ * This function takes a tile as input and removes the tile hooks
+ * that were added in addTileMonitoringHooks()
+ *
+ * Parameters:
+ * tile - {<OpenLayers.Tile>}
+ */
+ removeTileMonitoringHooks: function(tile) {
+ tile.events.register("loadstart", this, tile.onLoadStartTile);
+ tile.events.register("loadend", this, tile.onLoadEndTile);
+ },
+
/**
* Method: initGriddedTiles
*
@@ -392,7 +402,9 @@
while (this.grid.length > rowidx) {
var row = this.grid.pop();
for (var i=0, l=row.length; i<l; i++) {
- row[i].destroy();
+ var tile = row[i];
+ this.removeTileMonitoringHooks(tile)
+ tile.destroy();
}
}
@@ -401,6 +413,7 @@
for (var i=0, l=this.grid.length; i<l; i++) {
var row = this.grid[i];
var tile = row.pop();
+ this.removeTileMonitoringHooks(tile);
tile.destroy();
}
}
More information about the Commits
mailing list