OpenLayers OpenLayers

Ticket #796: addLayerWarning.patch

File addLayerWarning.patch, 0.6 kB (added by euzuro, 1 year ago)

we catch this case and return false, perfect example of when to use a console.warn()

  • lib/OpenLayers/Map.js

    old new  
    483483    addLayer: function (layer) { 
    484484        for(var i=0; i < this.layers.length; i++) { 
    485485            if (this.layers[i] == layer) { 
     486                var msg = "You tried to add the layer: " + layer.name +  
     487                          " to the map, but it has already been added"; 
     488                OpenLayers.Console.warn(msg); 
    486489                return false; 
    487490            } 
    488491        }