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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<html>
<head>
<script type="text/javascript" src="../OLLoader.js"></script>
<script type="text/javascript">
// use an arcims map service against Avencia Inc.'s global sample map services
var serviceName = "OpenLayers_Sample";
var layerName = "Global Sample Map";
var imsUrl = "http://sample.avencia.com/servlet/com.esri.esrimap.Esrimap";
//
// create an arcims layer
//
function test_Layer_ArcIMS_constructor( t ) {
t.plan(11);
var options = {
serviceName: serviceName,
async: false,
displayOutsideMaxExtent: true
};
var layer = new OpenLayers.Layer.ArcIMS( layerName, imsUrl, options );
// check layer & properties
t.ok( layer instanceof OpenLayers.Layer.ArcIMS, "new OpenLayers.Layer.ArcIMS returns object" );
t.eq( layer.url, imsUrl, "layer.url is correct (HTTPRequest inited)" );
t.eq( layer.name, layerName, "layer.name is correct" );
t.eq( layer.displayOutsideMaxExtent, options.displayOutsideMaxExtent,
"displayOutsideMaxExtent property set correctly from options" );
// check request parameters
t.eq( layer.params.ServiceName, serviceName, "ServiceName set properly" );
t.eq( layer.params.ClientVersion, "9.2", "ClientVersion set properly" );
// check request options
t.eq( layer.options.async, options.async, "async property set correctly from options" );
t.eq( layer.options.serviceName, serviceName, "serviceName property set correctly from options" );
t.eq( layer.options.layers.length, 0, "layers option is the correct length" );
t.eq( layer.options.tileSize.w, 512, "default tile width set correctly" );
t.eq( layer.options.tileSize.h, 512, "default tile height set correctly" );
}
/*
* how to test getURL, getURLasync, and getFeatureInfo without a proxy?
*
*/
//
// Create an arcims layer, and verify that the query changes properly
//
function test_Layer_ArcIMS_setLayerQuery(t) {
t.plan(9);
var options = { serviceName: serviceName };
var layer = new OpenLayers.Layer.ArcIMS( layerName, imsUrl, options );
var querydef = {
where: "FIPS_CNTRY = 'US'"
};
t.eq( layer.options.layers.length, 0, "layer definitions are empty" );
layer.setLayerQuery( "layerID", querydef );
t.eq( layer.options.layers.length, 1, "layers definitions contain one layerdef" );
t.ok( layer.options.layers[0].query !== null, "layer query exists" );
t.eq( typeof layer.options.layers[0].query.where, "string", "where query is a string" );
t.eq( layer.options.layers[0].query.where, querydef.where, "where query matches" );
// change the definition
querydef = {
where: "FIPS_CNTRY = 'UV'",
spatialfilter:true
}
layer.setLayerQuery( "layerID", querydef );
t.eq( layer.options.layers.length, 1, "layers definitions contain one layerdef" );
t.ok( layer.options.layers[0].query !== null, "layer query exists" );
t.eq( typeof layer.options.layers[0].query.where, "string", "where query is a string" );
t.eq( layer.options.layers[0].query.where, querydef.where, "where query matches" );
}
function test_Layer_ArcIMS_clone (t) {
t.plan(5);
var url = imsUrl;
var options = {
serviceName: serviceName,
async: false,
displayOutsideMaxExtent: true
};
var map = new OpenLayers.Map('map', {controls: []});
var layer = new OpenLayers.Layer.ArcIMS(name, url, options);
map.addLayer(layer);
layer.grid = [ [6, 7],
[8, 9]];
var clone = layer.clone();
t.ok( clone.grid != layer.grid, "clone does not copy grid");
t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned");
t.eq( clone.params.serviceName, layer.params.serviceName, "serviceName copied correctly");
t.eq( clone.async, layer.async, "async copied correctly");
t.eq( clone.url, layer.url, "url copied correctly");
layer.grid = null;
map.destroy();
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>
|