"use different server when IMAGE_RELOAD_ATTEMPTS > 1 && layer.url is an array".

Patch from brentp. (Closes #1291)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@7599 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-07-30 02:02:36 +00:00
parent d41b6afec4
commit 2d301f456b
2 changed files with 27 additions and 2 deletions

View File

@@ -363,8 +363,27 @@ OpenLayers.IMAGE_RELOAD_ATTEMPTS = 0;
*/
OpenLayers.Util.onImageLoadError = function() {
this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
if(this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
this.src = this.src;
if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
var urls = this.urls;
if (urls && urls instanceof Array && urls.length > 1){
var src = this.src.toString();
var current_url, k;
for (k = 0; current_url = urls[k]; k++){
if(src.indexOf(current_url) != -1){
break;
}
}
var guess = Math.floor(urls.length * Math.random())
var new_url = urls[guess];
k = 0;
while(new_url == current_url && k++ < 4){
guess = Math.floor(urls.length * Math.random())
new_url = urls[guess];
}
this.src = src.replace(current_url, new_url);
} else {
this.src = this.src;
}
} else {
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
}