From 43a4f9320bfad1eb9a5fe59711b97ffb4e867977 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sat, 15 Dec 2007 14:16:18 +0000 Subject: [PATCH] Tile.Image should register for error events with respect to tile loading events -- this means that if an image fails to load, it will still trigger a loadend event, and the layer will eventually be in a state where it is no longer waiting to load. Thanks to Andreas for the investigation! (Closes #842) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5428 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Tile/Image.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 5d90e0ec0d..3976fc15ad 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -216,6 +216,21 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { OpenLayers.Event.observe(this.imgDiv, 'load', OpenLayers.Function.bind(onload, this)); + // Bind a listener to the onerror of the image div so that we + // can registere when a tile has finished loading with errors. + var onerror = function() { + + // If we have gone through all image reload attempts, it is time + // to realize that we are done with this image. Since + // OpenLayers.Util.onImageLoadError already has taken care about + // the error, we can continue as if the image was loaded + // successfully. + if (this.imgDiv._attempts > OpenLayers.IMAGE_RELOAD_ATTEMPTS) { + onload.call(this); + } + }; + OpenLayers.Event.observe(this.imgDiv, "error", + OpenLayers.Function.bind(onerror, this)); }, /**