"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:
@@ -86,6 +86,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
this.frame.removeChild(this.imgDiv);
|
this.frame.removeChild(this.imgDiv);
|
||||||
this.imgDiv.map = null;
|
this.imgDiv.map = null;
|
||||||
}
|
}
|
||||||
|
this.imgDiv.urls = null;
|
||||||
}
|
}
|
||||||
this.imgDiv = null;
|
this.imgDiv = null;
|
||||||
if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) {
|
if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) {
|
||||||
@@ -161,6 +162,11 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
|
|
||||||
this.imgDiv.viewRequestID = this.layer.map.viewRequestID;
|
this.imgDiv.viewRequestID = this.layer.map.viewRequestID;
|
||||||
|
|
||||||
|
// needed for changing to a different serve for onload error
|
||||||
|
if (this.layer.url instanceof Array) {
|
||||||
|
this.imgDiv.urls = this.layer.url.slice();
|
||||||
|
}
|
||||||
|
|
||||||
this.url = this.layer.getURL(this.bounds);
|
this.url = this.layer.getURL(this.bounds);
|
||||||
// position the frame
|
// position the frame
|
||||||
OpenLayers.Util.modifyDOMElement(this.frame,
|
OpenLayers.Util.modifyDOMElement(this.frame,
|
||||||
|
|||||||
@@ -363,8 +363,27 @@ OpenLayers.IMAGE_RELOAD_ATTEMPTS = 0;
|
|||||||
*/
|
*/
|
||||||
OpenLayers.Util.onImageLoadError = function() {
|
OpenLayers.Util.onImageLoadError = function() {
|
||||||
this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
|
this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
|
||||||
if(this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
|
if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
|
||||||
this.src = this.src;
|
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 {
|
} else {
|
||||||
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
|
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user