OpenLayers OpenLayers

Changeset 6495

Show
Ignore:
Timestamp:
03/12/08 08:53:34 (10 months ago)
Author:
crschmidt
Message:

Improve the handling of tile events with regard to tiles being unloaded before
their load events fire by adding an 'unload' event to the tile, and calling
it from the places where we're about to stop listening to events. In the longer
term, it might make sense to have this be automatic, but this resolves issues
with map resizes screwing with tile events, and reverts a previous,
incomplete solution to solve a problem with untiled tiles not resizing when
the map size changes. r=ahocevar, checked out by bartvde (Closes #1417)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Layer/Grid.js

    r6437 r6495  
    548548        }; 
    549549        tile.events.register("loadend", this, tile.onLoadEnd); 
     550        tile.events.register("unload", this, tile.onLoadEnd); 
    550551    }, 
    551552 
     
    559560     */ 
    560561    removeTileMonitoringHooks: function(tile) { 
     562        tile.unload() 
    561563        tile.events.un({ 
    562564            "loadstart": tile.onLoadStart, 
    563565            "loadend": tile.onLoadEnd, 
     566            "unload": tile.onLoadEnd, 
    564567            scope: this 
    565568        }); 
     
    701704    onMapResize: function() { 
    702705        if (this.singleTile) { 
     706            this.clearGrid(); 
    703707            this.setTileSize(); 
    704708        } 
  • trunk/openlayers/lib/OpenLayers/Layer/WFS.js

    r6422 r6495  
    342342        }; 
    343343        tile.events.register("loadend", tile, tile.onLoadEnd); 
     344        tile.events.register("unload", tile, tile.onLoadEnd); 
    344345    }, 
    345346     
     
    353354     */ 
    354355    removeTileMonitoringHooks: function(tile) { 
     356        tile.unload(); 
    355357        tile.events.un({ 
    356358            "loadstart": tile.onLoadStart, 
    357359            "loadend": tile.onLoadEnd, 
     360            "unload": tile.onLoadEnd, 
    358361            scope: tile 
    359362        }); 
  • trunk/openlayers/lib/OpenLayers/Tile.js

    r6452 r6495  
    2626     * {Array(String)} Supported application event types 
    2727     */ 
    28     EVENT_TYPES: [ "loadstart", "loadend", "reload"], 
     28    EVENT_TYPES: [ "loadstart", "loadend", "reload", "unload"], 
    2929     
    3030    /** 
     
    137137         
    138138        this.events = new OpenLayers.Events(this, null, this.EVENT_TYPES); 
     139    }, 
     140 
     141    /** 
     142     * Method: unload 
     143     * Call immediately before destroying if you are listening to tile 
     144     * events, so that counters are properly handled if tile is still 
     145     * loading at destroy-time. Will only fire an event if the tile is 
     146     * still loading. 
     147     */ 
     148    unload: function() { 
     149       if (this.isLoading) {  
     150           this.isLoading = false;  
     151           this.events.triggerEvent("unload");  
     152       } 
    139153    }, 
    140154