blob: 4aa867f804e3d040439b74a162094341e66aa6ff (
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
61
62
63
64
65
66
|
<html>
<head>
<script src="../OLLoader.js"></script>
<script src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js"></script>
<script type="text/javascript">
function test_initialize(t) {
t.plan(2);
var options = {};
var map = new OpenLayers.Map("map",{projection:"EPSG:4326"});
var layer = new OpenLayers.Layer.WMS();
map.addLayers([layer]);
var control = new OpenLayers.Control.Graticule(options);
map.addControl(control);
map.zoomToMaxExtent();
t.ok(control.gratLayer instanceof OpenLayers.Layer.Vector,
"constructor sets layer correctly");
t.ok(control.gratLayer.features.length > 0,
"graticule has features");
control.destroy();
}
function test_activate(t) {
t.plan(7);
var map = new OpenLayers.Map("map",{projection:"EPSG:4326"});
var layer = new OpenLayers.Layer.WMS();
map.addLayers([layer]);
var control = new OpenLayers.Control.Graticule({});
map.addControl(control);
map.zoomToMaxExtent();
t.ok(control.gratLayer.visibility, "Graticule layer is visible by default");
control.deactivate();
t.ok(control.gratLayer.map == null,
"Graticule layer is not in map when control is deactivated");
control.destroy();
var control2 = new OpenLayers.Control.Graticule({autoActivate:false});
map.addControl(control2);
t.ok(control2.gratLayer.map == null,
"Graticule layer is not in map when autoActivate:false");
t.ok(control2.gratLayer.features.length == 0,
"Graticule layer is empty when autoActivate:false");
control2.activate();
t.ok(control2.gratLayer.map != null,
"Graticule layer is on map when control is activated");
t.ok(control2.gratLayer.features.length > 0,
"Graticule features refreshed after control is activated");
control2.gratLayer.setVisibility(false);
control2.destroy();
t.ok(control2.gratLayer == null,
"Graticule layer is destroyed when control is destroyed");
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width: 400px; height: 250px;"/>
</body>
</html>
|