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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<html>
<head>
<script src="../../../OLLoader.js"></script>
<script src="../../../../lib/deprecated.js"></script>
<script type="text/javascript">
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
var layer;
var name = 'Test Layer';
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
var params = { map: '/mapdata/vmap_wms.map',
layers: 'basic',
format: 'image/jpeg'};
function test_Layer_WMS_Post_constructor (t) {
t.plan( 2 );
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
var options = {unsupportedBrowsers: []};
layer = new OpenLayers.Layer.WMS.Post(name, url, params, options);
t.eq(
layer.usePost, true,
"Supported browsers use IFrame tiles.");
layer.destroy();
var options = { unsupportedBrowsers: [OpenLayers.BROWSER_NAME]};
layer = new OpenLayers.Layer.WMS.Post(name, url, params, options);
t.eq(
layer.usePost, false,
"unsupported browsers use Image tiles.");
layer.destroy();
}
function test_Layer_WMS_Post_addtile (t) {
t.plan( 3 );
layer = new OpenLayers.Layer.WMS.Post(name, url, params);
var map = new OpenLayers.Map('map');
map.addLayer(layer);
var bounds = new OpenLayers.Bounds(1,2,3,4);
var pixel = new OpenLayers.Pixel(5,6);
var tile = layer.addTile(bounds, pixel);
if(isMozilla || isOpera) {
t.ok(
tile instanceof OpenLayers.Tile.Image,
"tile is an instance of OpenLayers.Tile.Image");
}
else {
t.ok(
tile.useIFrame !== undefined,
"tile is created with the OpenLayers.Tile.Image.IFrame mixin");
}
map.destroy();
// test the unsupported browser
layer = new OpenLayers.Layer.WMS.Post(name, url, params, {
unsupportedBrowsers: [OpenLayers.BROWSER_NAME]
});
map = new OpenLayers.Map('map');
map.addLayer(layer);
tile = layer.addTile(bounds, pixel);
t.ok(
tile instanceof OpenLayers.Tile.Image,
"unsupported browser: tile is an instance of Tile.Image");
layer.destroy();
// test a supported browser
layer = new OpenLayers.Layer.WMS.Post(name, url, params, {
unsupportedBrowsers: []
});
map.addLayer(layer);
var tile2 = layer.addTile(bounds, pixel);
tile2.draw();
t.eq(
tile2.useIFrame, true,
"supported browser: tile is created with the Tile.Image.IFrame mixin");
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>
|