[OpenLayers-Dev] image load retry using onImageLoadError in util.js does not seem to work well

Anne Blankert anne.blankert at geodan.nl
Wed Mar 31 10:58:38 EDT 2010


File util.js has a function 'onImageLoadError'. This function is called 
when an map-image or tile fails to load. There can be many reasons for a 
tile to fail to load. Therefore it is sometimes a good idea to 
automatically try to reload the tile. In order to do this, you can tell 
OpenLayers to try another URL, but another URL is not required. Instead, 
you can just set OpenLayers.IMAGE_RELOAD_ATTEMPTS to some number greater 
than 1 and the retry should work.

However, in util.js the retry is implemented using the following 
javascript code:

this.src = this.src

In IE7, FireFox 3.6 and Chrome this does not seem to result in a new 
request to the map server.

The following hack seems to work fine for my puposes:
this.src=this.src.replace('?', '?retry=' + this._attemps + '&');

Are there better ways to solve the problem of reloading the image? Here, 
the URL is modified, which could, at least theoretically, have some 
unexpected side effects.


More information about the Dev mailing list