OpenLayers OpenLayers

Changeset 7599

Show
Ignore:
Timestamp:
07/30/08 02:02:36 (4 months ago)
Author:
crschmidt
Message:

"use different server when IMAGE_RELOAD_ATTEMPTS > 1 && layer.url is an array".
Patch from brentp. (Closes #1291)

Files:

Legend:

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

    r6638 r7599  
    8787                this.imgDiv.map = null; 
    8888            } 
     89            this.imgDiv.urls = null; 
    8990        } 
    9091        this.imgDiv = null; 
     
    161162 
    162163        this.imgDiv.viewRequestID = this.layer.map.viewRequestID; 
     164         
     165        // needed for changing to a different serve for onload error 
     166        if (this.layer.url instanceof Array) { 
     167            this.imgDiv.urls = this.layer.url.slice(); 
     168        } 
    163169         
    164170        this.url = this.layer.getURL(this.bounds); 
  • trunk/openlayers/lib/OpenLayers/Util.js

    r7329 r7599  
    364364OpenLayers.Util.onImageLoadError = function() { 
    365365    this._attempts = (this._attempts) ? (this._attempts + 1) : 1; 
    366     if(this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) { 
    367         this.src = this.src; 
     366    if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) { 
     367        var urls = this.urls; 
     368        if (urls && urls instanceof Array && urls.length > 1){ 
     369            var src = this.src.toString(); 
     370            var current_url, k; 
     371            for (k = 0; current_url = urls[k]; k++){ 
     372                if(src.indexOf(current_url) != -1){ 
     373                    break; 
     374                } 
     375            } 
     376            var guess = Math.floor(urls.length * Math.random()) 
     377            var new_url = urls[guess]; 
     378            k = 0; 
     379            while(new_url == current_url && k++ < 4){ 
     380                guess = Math.floor(urls.length * Math.random()) 
     381                new_url = urls[guess]; 
     382            } 
     383            this.src = src.replace(current_url, new_url); 
     384        } else { 
     385            this.src = this.src; 
     386        } 
    368387    } else { 
    369388        this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;