OpenLayers OpenLayers

Ticket #596: 596.patch

File 596.patch, 0.9 kB (added by sderle, 2 years ago)

tschaub's take on euzuro's original patch, plus a similar fix for map.controls just in case

  • lib/OpenLayers/Map.js

    old new  
    243243        this.unloadDestroy = null; 
    244244 
    245245        if (this.layers != null) { 
    246             for(var i=0; i< this.layers.length; i++) { 
     246            for (var i = this.layers.length - 1; i>=0; --i) { 
    247247                //pass 'false' to destroy so that map wont try to set a new  
    248248                // baselayer after each baselayer is removed 
    249249                this.layers[i].destroy(false); 
     
    251251            this.layers = null; 
    252252        } 
    253253        if (this.controls != null) { 
    254             for(var i=0; i< this.controls.length; i++) { 
     254            for (var i = this.controls.length - 1; i>=0; --i) { 
    255255                this.controls[i].destroy(); 
    256256            }  
    257257            this.controls = null;