OpenLayers OpenLayers

Changeset 3628

Show
Ignore:
Timestamp:
07/06/07 16:15:42 (1 year ago)
Author:
euzuro
Message:

add function to remove hooks from tiles

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/euzuro/untiled3/lib/OpenLayers/Layer/Grid.js

    r3613 r3628  
    8787                var row = this.grid[iRow]; 
    8888                for(var iCol=0; iCol < row.length; iCol++) { 
    89                     row[iCol].destroy(); 
     89                    var tile = row[iCol]; 
     90                    this.removeTileMonitoringHooks(tile); 
     91                    tile.destroy(); 
    9092                } 
    9193            } 
     
    277279    addTileMonitoringHooks: function(tile) { 
    278280         
    279         var onLoadStart = function() { 
    280                  
    281             //if there are no tiles loading then trigger a 'loadstart' 
    282             // event on the layer 
     281        tile.onLoadStart = function() { 
     282            //if that was first tile then trigger a 'loadstart' on the layer 
    283283            if (this.numLoadingTiles == 0) { 
    284284                this.events.triggerEvent("loadstart"); 
     
    286286             
    287287            this.numLoadingTiles++; 
    288  
    289288        }; 
    290         tile.events.register("loadstart", 
    291                              this, 
    292                              onLoadStart.bindAsEventListener(this)); 
     289        tile.events.register("loadstart", this, tile.onLoadStart); 
    293290       
    294         var onLoadEnd = function() { 
     291        tile.onLoadEnd = function() { 
    295292            this.numLoadingTiles--; 
     293            //if that was the last tile, then trigger a 'loadend' on the layer 
    296294            if (this.numLoadingTiles == 0) { 
    297295                this.events.triggerEvent("loadend"); 
    298296            } 
    299297        }; 
    300         tile.events.register("loadend", 
    301                              this, 
    302                              onLoadEnd.bindAsEventListener(this)); 
    303     }, 
    304  
    305   
     298        tile.events.register("loadend", this, tile.onLoadEnd); 
     299    }, 
     300 
     301 
     302 
     303    /**  
     304     * Method: removeTileMonitoringHooks 
     305     * This function takes a tile as input and removes the tile hooks  
     306     *     that were added in addTileMonitoringHooks() 
     307     *  
     308     * Parameters:  
     309     * tile - {<OpenLayers.Tile>} 
     310     */ 
     311    removeTileMonitoringHooks: function(tile) { 
     312        tile.events.register("loadstart", this, tile.onLoadStartTile); 
     313        tile.events.register("loadend", this, tile.onLoadEndTile); 
     314    }, 
     315     
    306316    /** 
    307317     * Method: initGriddedTiles 
     
    393403            var row = this.grid.pop(); 
    394404            for (var i=0, l=row.length; i<l; i++) { 
    395                 row[i].destroy(); 
     405                var tile = row[i]; 
     406                this.removeTileMonitoringHooks(tile) 
     407                tile.destroy(); 
    396408            } 
    397409        } 
     
    402414                var row = this.grid[i]; 
    403415                var tile = row.pop(); 
     416                this.removeTileMonitoringHooks(tile); 
    404417                tile.destroy(); 
    405418            }