OpenLayers OpenLayers

Ticket #596: mapDestroy.patch

File mapDestroy.patch, 0.7 kB (added by euzuro, 2 years ago)

use while instead of for. now all the layers go bye

  • 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            while(this.layers.length) { 
    247247                //pass 'false' to destroy so that map wont try to set a new  
    248248                // baselayer after each baselayer is removed 
    249                 this.layers[i].destroy(false); 
     249                this.layers[0].destroy(false); 
    250250            }  
    251251            this.layers = null; 
    252252        }