forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_utfgrid.js
More file actions
86 lines (79 loc) · 2.96 KB
/
script_utfgrid.js
File metadata and controls
86 lines (79 loc) · 2.96 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
$(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',
wmslayers: ['poly_landmarks', 'tiger_roads', 'poi'].join(),
controls: [],
projection: 'EPSG:900913',
displayProjection: 'EPSG:4326',
format: 'image/png',
wmsparams: {
'MAP_TYPE': 'SPH'
}
};
init = function () {
var lon = -73.9529, lat = 40.7723, zoom = 10,
map, sharpmap, utfgrid, callback, control, center, infoc = $('#info');
map = new OpenLayers.Map('map', options);
sharpmap = new OpenLayers.Layer.WMS(
'SharpMap WMS',
'/wms.ashx', {
layers: options.wmslayers,
service: options.wms,
version: '1.3.0',
format: options.format,
transparent: true
}, {
isBaseLayer: false,
transparent: true,
visibility: true,
buffer: 0,
singleTile: false,
ratio: 1.5
});
sharpmap.mergeNewParams(options.wmsparams);
utfgrid = new OpenLayers.Layer.UTFGrid({
name: 'UTF Grid',
url: "/UtfGrid/GetData/?layer=poly_landmarks&z=${z}&x=${x}&y=${y}",
utfgridResolution: 2,
displayInLayerSwitcher: true
});
map.addLayers([new OpenLayers.Layer.OSM(), sharpmap, utfgrid]);
callback = function (lookup) {
var info, msg;
if (lookup) {
for (var idx in lookup) {
info = lookup[idx];
if (info && info.data) {
msg = '[' + info.id + ']: LANAME: ' + info.data.LANAME + ', CFCC: ' + info.data.CFCC;
infoc.text(msg);
} else {
infoc.text('');
}
}
}
};
control = new OpenLayers.Control.UTFGrid({
callback: callback,
handlerMode: "move"
});
map.addControl(control);
map.addControl(new OpenLayers.Control.PanZoom({
position: new OpenLayers.Pixel(2, 10)
}));
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.LoadingPanel());
center = new OpenLayers.LonLat(lon, lat);
center.transform(options.displayProjection, options.projection);
map.setCenter(center, zoom);
};
init();
});