OpenLayers OpenLayers

Ticket #103: 103.3.patch

File 103.3.patch, 3.2 kB (added by crschmidt, 10 months ago)
  • tests/Control/test_Attribution.html

    old new  
    1010        t.ok( control instanceof OpenLayers.Control.Attribution, "new OpenLayers.Control returns object" ); 
    1111        t.eq( control.displayClass,  "olControlAttribution", "displayClass is correct" ); 
    1212    } 
     13    function test_Control_Attribution_setBaseLayer (t) { 
     14        t.plan(1); 
     15        map = new OpenLayers.Map("map"); 
     16        map.addControl(control); 
     17        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer!', isBaseLayer: true})); 
     18        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 2!', isBaseLayer: true})); 
     19        map.setBaseLayer(map.layers[1]); 
     20        t.eq(control.div.innerHTML, 'My layer 2!', "Attribution correct with changed base layer"); 
     21 
     22    } 
    1323    function test_Control_Attribution_draw (t) { 
    1424        t.plan(3); 
    1525        control = new OpenLayers.Control.Attribution(); 
     
    1929        t.eq(control.div.innerHTML, 'My layer!', "Attribution correct with one layer."); 
    2030        map.addLayer(new OpenLayers.Layer("name", {'attribution':'My layer 2!'})); 
    2131        t.eq(control.div.innerHTML, 'My layer!, My layer 2!', "Attribution correct with two layers."); 
    22         control.seperator = '|'; 
     32        control.separator = '|'; 
    2333        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 3!'})); 
    2434        t.eq(control.div.innerHTML, 'My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator."); 
     35 
     36 
    2537    }     
    2638  // --> 
    2739  </script> 
  • lib/OpenLayers/Control/Attribution.js

    old new  
    1616     * APIProperty: seperator 
    1717     * {String} String used to seperate layers. 
    1818     */ 
    19     seperator: ", ", 
     19    separator: ", ", 
    2020        
    2121    /** 
    2222     * Constructor: OpenLayers.Control.Attribution  
     
    3636        this.map.events.unregister("removelayer", this, this.updateAttribution); 
    3737        this.map.events.unregister("addlayer", this, this.updateAttribution); 
    3838        this.map.events.unregister("changelayer", this, this.updateAttribution); 
     39        this.map.events.unregister("changebaselayer", this, this.updateAttribution); 
    3940         
    4041        OpenLayers.Control.prototype.destroy.apply(this, arguments); 
    4142    },     
     
    5051    draw: function() { 
    5152        OpenLayers.Control.prototype.draw.apply(this, arguments); 
    5253         
     54        this.map.events.register('changebaselayer', this, this.updateAttribution); 
    5355        this.map.events.register('changelayer', this, this.updateAttribution); 
    5456        this.map.events.register('addlayer', this, this.updateAttribution); 
    5557        this.map.events.register('removelayer', this, this.updateAttribution); 
     
    7072                attributions.push( layer.attribution ); 
    7173            } 
    7274        }   
    73         this.div.innerHTML = attributions.join(this.seperator); 
     75        this.div.innerHTML = attributions.join(this.separator); 
    7476    }, 
    7577 
    7678    /** @final @type String */