forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_def.js
More file actions
76 lines (69 loc) · 2.54 KB
/
script_def.js
File metadata and controls
76 lines (69 loc) · 2.54 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
$(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:4326',
format: 'image/png',
wmsparams: {
'MAP_TYPE': 'DEF'
}
};
init = function () {
var lon = -73.9529, lat = 40.7723, zoom = 10,
map, sharpmap, click, toolbar, center;
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: true,
transparent: true,
visibility: true,
buffer: 0,
singleTile: false,
ratio: 1.5
});
sharpmap.mergeNewParams(options.wmsparams);
map.addLayers([sharpmap]);
click = new OpenLayers.Control.WMSGetFeatureInfo({
url: '/wms.ashx',
title: 'Identify features by clicking',
layers: [sharpmap],
vendorParams: options.wmsparams,
queryVisible: true
});
click.events.register("getfeatureinfo", this, function (evt) {
alert(evt.text);
});
toolbar = OpenLayers.Class(OpenLayers.Control.NavToolbar, {
initialize: function () {
OpenLayers.Control.NavToolbar.prototype.initialize.apply(this, [options]);
this.addControls([click]);
}
});
map.addControl(new OpenLayers.Control.LayerSwitcher());
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(new toolbar());
center = new OpenLayers.LonLat(lon, lat);
map.setCenter(center, zoom);
};
init();
});