forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_geojs.js
More file actions
92 lines (84 loc) · 3.62 KB
/
script_geojs.js
File metadata and controls
92 lines (84 loc) · 3.62 KB
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
$(document).ready(function () {
var options, init;
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
OpenLayers.Util.onImageLoadErrorColor = 'transparent';
OpenLayers.Util.onImageLoadError = function () {
this.src = '/Content/Images/sorry.jpg';
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
};
options = {
wms: 'WMS',
controls: [],
projection: 'EPSG:900913',
displayProjection: 'EPSG:4326',
format: 'text/json'
};
init = function () {
var lon = -73.9529, lat = 40.7723, zoom = 10,
map, url, layers = [], center, highlight;
map = new OpenLayers.Map('map', options);
map.addLayer(new OpenLayers.Layer.OSM());
url = [
'/wms.ashx',
'?SERVICE=', options.wms,
'&FORMAT=', options.format,
'&CRS=', options.projection,
'&REQUEST=GETFEATUREINFO&VERSION=1.3.0&STYLES=&WIDTH=20&HEIGHT=20&I=10&J=10&MAP_TYPE=SPH&LAYERS=poi,tiger_roads,poly_landmarks',
'&FEATURE_COUNT=0', // NOTE: ignored for json requests
'&INFO_FORMAT=', options.format
].join('');
layers.push(
new OpenLayers.Layer.Vector(
'POI', {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.HTTP({
url: [url, '&QUERY_LAYERS=poi'].join(''),
format: new OpenLayers.Format.GeoJSON()
}),
styleMap: OpenLayers.Resources.Styles.Layers.editable,
visibility: false
}));
layers.push(
new OpenLayers.Layer.Vector(
'Roads', {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.HTTP({
url: [url, '&QUERY_LAYERS=tiger_roads'].join(''),
format: new OpenLayers.Format.GeoJSON()
}),
styleMap: OpenLayers.Resources.Styles.Layers.editable,
visibility: false
}));
layers.push(
new OpenLayers.Layer.Vector(
'Landmarks', {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.HTTP({
url: [url, '&QUERY_LAYERS=poly_landmarks'].join(''),
format: new OpenLayers.Format.GeoJSON()
}),
styleMap: OpenLayers.Resources.Styles.Layers.editable,
visibility: false
}));
map.addLayers(layers.reverse());
highlight = new OpenLayers.Control.SelectFeatureEx(layers, {
hover: true,
highlightOnly: true,
renderIntent: 'temporary'
});
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.NavToolbar());
map.addControl(new OpenLayers.Control.PanZoom({
position: new OpenLayers.Pixel(2, 10)
}));
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.LoadingPanel());
map.addControl(highlight);
highlight.activate();
center = new OpenLayers.LonLat(lon, lat);
center.transform(options.displayProjection, options.projection);
map.setCenter(center, zoom);
};
init();
});