summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Control/Attribution.html
blob: 04b85cfdb3d25e44eeb8ef75ebad5d7ae7532128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<html>
<head>
  <script src="../OLLoader.js"></script>
  <script type="text/javascript">
    var map; 
    function test_Control_Attribution_constructor (t) {
        t.plan( 2 );
    
        control = new OpenLayers.Control.Attribution();
        t.ok( control instanceof OpenLayers.Control.Attribution, "new OpenLayers.Control returns object" );
        t.eq( control.displayClass,  "olControlAttribution", "displayClass is correct" );
    }
    function test_Control_Attribution_setBaseLayer (t) {
        t.plan(1);
        map = new OpenLayers.Map("map");
        map.addControl(control);
        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer!', isBaseLayer: true}));
        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 2!', isBaseLayer: true}));
        map.setBaseLayer(map.layers[1]);
        t.eq(control.div.innerHTML, 'My layer 2!', "Attribution correct with changed base layer");

    }
    function test_Control_Attribution_draw (t) {
        t.plan(3);
        control = new OpenLayers.Control.Attribution();
        map = new OpenLayers.Map("map");
        map.addControl(control);
        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer!'}));
        t.eq(control.div.innerHTML, 'My layer!', "Attribution correct with one layer.");
        map.addLayer(new OpenLayers.Layer("name", {'attribution':'My layer 2!'}));
        t.eq(control.div.innerHTML, 'My layer!, My layer 2!', "Attribution correct with two layers.");
        control.separator = '|';
        control.template = "Map Copyright (c) 2012 by Foo Bar; ${layers}";
        map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 3!'}));
        t.eq(control.div.innerHTML, 'Map Copyright (c) 2012 by Foo Bar; My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator.");


    }    
    
    function test_Control_Attribution_no_duplicates(t) {
        t.plan(2);
        
        map = new OpenLayers.Map("map");
        map.addLayer(new OpenLayers.Layer("Company A: 1",{'attribution':'company A'}));
        map.addLayer(new OpenLayers.Layer("Company A: 2",{'attribution':'company A'}));

        control = new OpenLayers.Control.Attribution();
        map.addControl(control);
        t.eq(control.div.innerHTML, 'company A', "Attribution not duplicated.");
                
        map.addLayer(new OpenLayers.Layer("Company B: 1",{'attribution':'company B'}));
        map.addLayer(new OpenLayers.Layer("Company A: 3",{'attribution':'company A'}));
        t.eq(control.div.innerHTML, 'company A, company B', "Attribution correct with four layers (3 with same attribution).");
    }
  </script>
</head>
<body>
    <div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>