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) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6495 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -547,6 +547,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
}
|
||||
};
|
||||
tile.events.register("loadend", this, tile.onLoadEnd);
|
||||
tile.events.register("unload", this, tile.onLoadEnd);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -558,9 +559,11 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
* tile - {<OpenLayers.Tile>}
|
||||
*/
|
||||
removeTileMonitoringHooks: function(tile) {
|
||||
tile.unload()
|
||||
tile.events.un({
|
||||
"loadstart": tile.onLoadStart,
|
||||
"loadend": tile.onLoadEnd,
|
||||
"unload": tile.onLoadEnd,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
@@ -700,6 +703,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
*/
|
||||
onMapResize: function() {
|
||||
if (this.singleTile) {
|
||||
this.clearGrid();
|
||||
this.setTileSize();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -341,6 +341,7 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
}
|
||||
};
|
||||
tile.events.register("loadend", tile, tile.onLoadEnd);
|
||||
tile.events.register("unload", tile, tile.onLoadEnd);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -352,9 +353,11 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
* tile - {<OpenLayers.Tile>}
|
||||
*/
|
||||
removeTileMonitoringHooks: function(tile) {
|
||||
tile.unload();
|
||||
tile.events.un({
|
||||
"loadstart": tile.onLoadStart,
|
||||
"loadend": tile.onLoadEnd,
|
||||
"unload": tile.onLoadEnd,
|
||||
scope: tile
|
||||
});
|
||||
},
|
||||
|
||||
@@ -25,7 +25,7 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
* Constant: EVENT_TYPES
|
||||
* {Array(String)} Supported application event types
|
||||
*/
|
||||
EVENT_TYPES: [ "loadstart", "loadend", "reload"],
|
||||
EVENT_TYPES: [ "loadstart", "loadend", "reload", "unload"],
|
||||
|
||||
/**
|
||||
* APIProperty: events
|
||||
@@ -137,6 +137,20 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
|
||||
this.events = new OpenLayers.Events(this, null, this.EVENT_TYPES);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: unload
|
||||
* Call immediately before destroying if you are listening to tile
|
||||
* events, so that counters are properly handled if tile is still
|
||||
* loading at destroy-time. Will only fire an event if the tile is
|
||||
* still loading.
|
||||
*/
|
||||
unload: function() {
|
||||
if (this.isLoading) {
|
||||
this.isLoading = false;
|
||||
this.events.triggerEvent("unload");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
|
||||
Reference in New Issue
Block a user