1 | /**
|
---|
2 | * Var 'map' is set global, used in 'heatmap_extensions.js'.
|
---|
3 | */
|
---|
4 | var map;
|
---|
5 |
|
---|
6 | function init_heatmap(){
|
---|
7 | var lat = getURLParameter('lat');
|
---|
8 | var lon = getURLParameter('lon');
|
---|
9 | var zoom = getURLParameter('zoom');
|
---|
10 |
|
---|
11 | if(lat=='null' || lon=='null' || zoom=='null'){
|
---|
12 | var lat = 52.15514;
|
---|
13 | var lon = 4.48959;
|
---|
14 | var zoom = 13;
|
---|
15 | }
|
---|
16 | var projection_wgs = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
|
---|
17 |
|
---|
18 | map = new OpenLayers.Map('heatmap', {
|
---|
19 | theme: null,
|
---|
20 | controls: [
|
---|
21 | new OpenLayers.Control.Navigation(),
|
---|
22 | new OpenLayers.Control.Permalink({
|
---|
23 | anchor : true,
|
---|
24 | createParams: function(center, zoom, layers) {
|
---|
25 | center = center || this.map.getCenter();
|
---|
26 |
|
---|
27 | var params = OpenLayers.Util.getParameters(this.base);
|
---|
28 |
|
---|
29 | // If there's still no center, map is not initialized yet.
|
---|
30 | // Break out of this function, and simply return the params from the
|
---|
31 | // base link.
|
---|
32 | if (center) {
|
---|
33 |
|
---|
34 | //zoom
|
---|
35 | params.zoom = zoom || this.map.getZoom();
|
---|
36 |
|
---|
37 | //lon,lat
|
---|
38 | var lat = center.lat;
|
---|
39 | var lon = center.lon;
|
---|
40 |
|
---|
41 | if (this.displayProjection) {
|
---|
42 | var mapPosition = OpenLayers.Projection.transform(
|
---|
43 | { x: lon, y: lat },
|
---|
44 | this.map.getProjectionObject(),
|
---|
45 | this.displayProjection );
|
---|
46 | lon = mapPosition.x;
|
---|
47 | lat = mapPosition.y;
|
---|
48 | }
|
---|
49 | params.lat = Math.round(lat*100000)/100000;
|
---|
50 | params.lon = Math.round(lon*100000)/100000;
|
---|
51 |
|
---|
52 | //layers
|
---|
53 | layers = layers || this.map.layers;
|
---|
54 | params.layers = '';
|
---|
55 | for (var i=0, len=layers.length; i<len; i++) {
|
---|
56 | var layer = layers[i];
|
---|
57 |
|
---|
58 | if (layer.isBaseLayer) {
|
---|
59 | params.layers += (layer == this.map.baseLayer) ? "B" : "0";
|
---|
60 | } else {
|
---|
61 | params.layers += (layer.getVisibility()) ? "T" : "F";
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 | //XXX: Hack custom filters in here
|
---|
66 | params.customParam = "foo";
|
---|
67 | return params;
|
---|
68 | }
|
---|
69 | }),
|
---|
70 | new OpenLayers.Control.PanZoomBar(),
|
---|
71 | new OpenLayers.Control.ZoomBox(),
|
---|
72 | new OpenLayers.Control.OverviewMap({
|
---|
73 | maximized : false,
|
---|
74 | mapOptions: { theme: null }
|
---|
75 | }),
|
---|
76 | new OpenLayers.Control.MousePosition({ 'displayProjection' : projection_wgs })
|
---|
77 | /**
|
---|
78 | * Decided to disable these controls.
|
---|
79 | * The layerswitcher has been replaced with a custom one. If you want the original back,
|
---|
80 | * make sure to disable the custom one to prevent collision.
|
---|
81 | */
|
---|
82 |
|
---|
83 | //new OpenLayers.Control.PanZoomBav(),
|
---|
84 | //new OpenLayers.Control.ScaleLine(),
|
---|
85 | //new OpenLayers.Control.LayerSwitcher(),
|
---|
86 | ],
|
---|
87 | maxExtent: new OpenLayers.Bounds(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892),
|
---|
88 | numZoomLevels:16,
|
---|
89 | maxResolution:156543.0339,
|
---|
90 | units:'m',
|
---|
91 | projection: "EPSG:900913",
|
---|
92 | displayProjection: new OpenLayers.Projection("EPSG:4326")
|
---|
93 | });
|
---|
94 |
|
---|
95 | map.events.register('click', map, GetMousePos);
|
---|
96 | function GetMousePos(pos) {
|
---|
97 | var pix = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x,pos.xy.y));
|
---|
98 | var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(pix.lon, pix.lat);
|
---|
99 | var zoomlevel = map.getZoom();
|
---|
100 | getNodeList(zoom, mousepos);
|
---|
101 | }
|
---|
102 |
|
---|
103 | layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
|
---|
104 | map.addLayer(layerMapnik);
|
---|
105 |
|
---|
106 | var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
|
---|
107 | map.setCenter (lonLat, zoom);
|
---|
108 |
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * Layers are created and put in switcher
|
---|
112 | */
|
---|
113 | function add_item(category, layer) {
|
---|
114 | map.addLayer(layer);
|
---|
115 | var checked = '';
|
---|
116 | if (layer.getVisibility()) { checked = "checked='checked'"; };
|
---|
117 | $("#" + category).append("<span id=\"" + layer.name + "\">" +
|
---|
118 | " <div id='layer_switcher_colour' style='background-color:rgb(" + layer.colour + ")' />" +
|
---|
119 | "<input type='checkbox' id='togglelayer' " + checked + " /><font>" + layer.name + " </font><br /></span>"
|
---|
120 | );
|
---|
121 | }
|
---|
122 |
|
---|
123 | var signallayer = new OpenLayers.Layer.OSM.Overlay4("signallayer", {isBaseLayer: false, visibility: false});
|
---|
124 | var wlsignalLayer = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Coverage", {isBaseLayer: false, visibility: true});
|
---|
125 | var nodesLayer = new OpenLayers.Layer.GML.NodesOverlay("Node Locations", {isBaseLayer: false, visibility: false});
|
---|
126 |
|
---|
127 | add_item('default', signallayer);
|
---|
128 | add_item('default', wlsignalLayer);
|
---|
129 | add_item('features', nodesLayer);
|
---|
130 | }
|
---|