source: core/trunk/tests/data/LayerStore.html @ 238

Last change on this file since 238 was 238, checked in by ahocevar, 9 years ago

Added MapPanel, LayerRecord and LayerStore with examples and tests; also contains license.txt file. Big thanks to sbenthall and tcoulter for their original input, to elemoine for the good discussion today about the LayerStoreMixin and his patience despite my angryness, to tschaub for the constructive comments, and finally to everyone who participated in the discussions on the mailing list about what we want this component to be. r=elemoine,tschaub (closes #4)

File size: 2.2 KB
Line 
1<!DOCTYPE html>
2<html debug="true">
3  <head>
4    <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script>
5    <script type="text/javascript" src="../../../../ext/2.2.1/adapter/ext/ext-base.js"></script>
6    <script type="text/javascript" src="../../../../ext/2.2.1/ext-all-debug.js"></script>
7    <script type="text/javascript" src="../../lib/GeoExt.js"></script>
8
9    <script type="text/javascript">
10       
11        function createMap() {
12            var map = new OpenLayers.Map();
13            return map;
14        }
15
16        function loadMapPanel() {
17            var map = createMap();
18
19            mapPanel = new GeoExt.MapPanel({
20                // panel options
21                id: "map-panel",
22                title: "GeoExt MapPanel",
23                renderTo: "mappanel",
24                height: 400,
25                width: 600,
26                // map panel-specific options
27                map: map,
28                center: new OpenLayers.LonLat(5, 45),
29                zoom: 4
30            });
31
32            return mapPanel;
33        }
34
35        function test_layerstore(t) {
36            t.plan(6);
37
38            var mapPanel = loadMapPanel();
39            var map = mapPanel.map;
40
41            var layer = new OpenLayers.Layer.Vector("Foo Layer");
42
43            map.addLayer(layer);
44
45            t.eq(map.layers.length,1,"Adding layer to map does not create duplicate layers on map");
46            t.eq(mapPanel.layers.getCount(),1,"Adding layer to map does not create duplicate records in LayerStore");
47
48            mapPanel.layers.remove(mapPanel.layers.getById(layer.id));
49
50            t.eq(map.layers.length,0,"removeLayer on MapPanel's LayerStore removes layer from map");
51            t.eq(mapPanel.layers.getCount(),0,"removeLayer on MapPanel's LayerStore removes layer from map");
52
53            mapPanel.layers.add(new GeoExt.data.LayerRecord(layer));
54            t.eq(map.layers.length,1,"Adding layer to MapPanel's LayerStore adds only one layer to map");
55            t.eq(mapPanel.layers.getCount(),1,"Adding layers to MapPanel's LayerStore does not create duplicate layers");
56
57
58        }
59    </script>
60  <body>
61    <div id="mappanel"></div>
62  </body>
63</html>
Note: See TracBrowser for help on using the repository browser.