OpenLayers OpenLayers

Ticket #1291: urls.patch

File urls.patch, 2.0 kB (added by brentp, 10 months ago)
  • lib/OpenLayers/Tile/Image.js

    old new  
    8282                this.frame.removeChild(this.imgDiv); 
    8383                this.imgDiv.map = null; 
    8484            } 
     85            this.imgDiv.layer = null; 
    8586        } 
    8687        this.imgDiv = null; 
    8788        if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) { 
     
    119120        } 
    120121 
    121122        this.imgDiv.viewRequestID = this.layer.map.viewRequestID; 
     123 
     124        // needed for changing to a different serve for onload error 
     125        this.imgDiv.layer = this.layer; 
     126 
    122127 
    123128        this.url = this.layer.getURL(this.bounds); 
    124129        // position the frame 
  • lib/OpenLayers/Util.js

    old new  
    349349OpenLayers.Util.onImageLoadError = function() { 
    350350    this._attempts = (this._attempts) ? (this._attempts + 1) : 1; 
    351351    if(this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) { 
    352         this.src = this.src; 
     352        var urls = this.layer.url; 
     353        if(urls instanceof Array && urls.length > 1){ 
     354            var src = this.src.toString(); 
     355            var current_url, k; 
     356            for (k = 0; current_url = urls[k]; k++){ 
     357                if(src.indexOf(current_url) != -1){ 
     358                    break; 
     359                } 
     360            } 
     361            var guess = Math.floor(urls.length * Math.random()) 
     362            var new_url = urls[guess]; 
     363            k = 0; 
     364            while(new_url == current_url && k++ < 4){ 
     365                guess = Math.floor(urls.length * Math.random()) 
     366                new_url = urls[guess]; 
     367            } 
     368            this.src = src.replace(current_url, new_url); 
     369        } else { 
     370            this.src = this.src; 
     371        } 
    353372    } else { 
    354373        this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor; 
    355374    }