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)); }, /**