OpenLayers OpenLayers

Changeset 5428

Show
Ignore:
Timestamp:
12/15/07 09:16:18 (1 year ago)
Author:
crschmidt
Message:

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)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Tile/Image.js

    r5284 r5428  
    217217                                 OpenLayers.Function.bind(onload, this)); 
    218218 
     219        // Bind a listener to the onerror of the image div so that we 
     220        // can registere when a tile has finished loading with errors. 
     221        var onerror = function() { 
     222 
     223            // If we have gone through all image reload attempts, it is time 
     224            // to realize that we are done with this image. Since 
     225            // OpenLayers.Util.onImageLoadError already has taken care about 
     226            // the error, we can continue as if the image was loaded 
     227            // successfully. 
     228            if (this.imgDiv._attempts > OpenLayers.IMAGE_RELOAD_ATTEMPTS) { 
     229                onload.call(this); 
     230            } 
     231        }; 
     232        OpenLayers.Event.observe(this.imgDiv, "error", 
     233                                 OpenLayers.Function.bind(onerror, this)); 
    219234    }, 
    220235