patch for #452 - Adding events to Layer class to signal the start, end, and cancelling of a layer load. Thanks to Bart for the idea and followthrough with this patch.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2200 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -30,7 +30,10 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
|
||||
/** @type OpenLayers.Tile.Image */
|
||||
tile: null,
|
||||
|
||||
|
||||
/** did the image finish loading before a new draw was initiated?
|
||||
* @type Boolean */
|
||||
doneLoading: false,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -108,6 +111,10 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
* @param {Boolean} dragging
|
||||
*/
|
||||
moveTo:function(bounds, zoomChanged, dragging) {
|
||||
if (!this.doneLoading) {
|
||||
this.events.triggerEvent("loadcancel");
|
||||
this.doneLoading = true;
|
||||
}
|
||||
OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this,arguments);
|
||||
|
||||
if (bounds == null) {
|
||||
@@ -155,10 +162,18 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
this.tile = null;
|
||||
}
|
||||
|
||||
this.events.triggerEvent("loadstart");
|
||||
this.doneLoading = false;
|
||||
if (!this.tile) {
|
||||
this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds,
|
||||
url, tileSize);
|
||||
this.tile.draw();
|
||||
var onload = function() {
|
||||
this.doneLoading = true;
|
||||
this.events.triggerEvent("loadend");
|
||||
}
|
||||
OpenLayers.Event.observe(this.tile.imgDiv, 'load',
|
||||
onload.bindAsEventListener(this));
|
||||
} else {
|
||||
this.tile.moveTo(tileBounds, pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user