source: src/django_gheat/website/static/heatmap.js@ 9317

Last change on this file since 9317 was 9316, checked in by dennisw, 13 years ago

Set Leiden as center of map.
Layerswitcher categories can be toggled now. Small changes to css.

File size: 3.6 KB
Line 
1/**
2 * Var 'map' is set global, used in 'heatmap_extensions.js'.
3 */
4var map;
5
6function init(){
7
8 var lat = getURLParameter('lat');
9 var lon = getURLParameter('lon');
10 var zoom = getURLParameter('zoom');
11
12 if(lat=='null' || lon=='null' || zoom=='null'){
13 var lat = 52.15514;
14 var lon = 4.48959;
15 var zoom = 13;
16 }
17 var projection_wgs = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
18
19 map = new OpenLayers.Map('heatmap', {
20 controls: [
21 new OpenLayers.Control.Navigation(),
22 new OpenLayers.Control.Permalink(),
23 new OpenLayers.Control.MousePosition({ 'displayProjection' : projection_wgs }),
24
25 /**
26 * Decided to disable these controls.
27 * The layerswitcher has been replaced with a custom one. If you want the original back,
28 * make sure to disable the custom one to prevent collision.
29 */
30
31 //new OpenLayers.Control.PanZoomBar(),
32 //new OpenLayers.Control.ScaleLine(),
33 //new OpenLayers.Control.LayerSwitcher(),
34 ],
35 maxExtent: new OpenLayers.Bounds(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892),
36 numZoomLevels:16,
37 maxResolution:156543.0339,
38 units:'m',
39 projection: "EPSG:900913",
40 displayProjection: new OpenLayers.Projection("EPSG:4326")
41 });
42
43 map.events.register('click', map, GetMousePos);
44 function GetMousePos(pos) {
45 var pix = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x,pos.xy.y));
46 var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(pix.lon, pix.lat);
47 var zoomlevel = map.getZoom();
48 getNodeList(zoom, mousepos);
49 }
50
51 layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
52 map.addLayer(layerMapnik);
53
54 layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: true});
55 map.addLayer(layerHeatmap2);
56
57 layerHeatmap3 = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Only", {isBaseLayer: false, visibility: true});
58 map.addLayer(layerHeatmap3);
59
60 layerHeatmap = new OpenLayers.Layer.OSM.Overlay1("Original Heatmap generator", {isBaseLayer: false, visibility: false});
61 map.addLayer(layerHeatmap);
62
63 var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
64 map.setCenter (lonLat, zoom);
65
66 signallayer = new OpenLayers.Layer.OSM.Overlay4("signallayer", {isBaseLayer: false, visibility: true});
67 map.addLayer(signallayer);
68
69 /**
70 * Layers above are put in switcher, category 'default', with code below.
71 * TODO: Make process for putting layers into layerswitcher dynamic instead of putting every layer there manually.
72 */
73
74 $("#default").append("<span id=\"" + layerHeatmap.name + "\"><input type=checkbox id=togglelayer /><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap.colour + ")' /><font>" + layerHeatmap.name + " </font><br /></span>");
75
76 $("#default").append("<span id=\"" + layerHeatmap2.name + "\"><input type=checkbox id=togglelayer checked/><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap2.colour + ")' /><font>" + layerHeatmap2.name + " </font><br /></span>");
77
78 $("#default").append("<span id=\"" + layerHeatmap3.name + "\"><input type=checkbox id=togglelayer checked/><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap3.colour + ")' /><font>" + layerHeatmap3.name + " </font><br /></span>");
79
80 $("#default").append("<span id=\"" + signallayer.name + "\"><input type=checkbox id=togglelayer checked /><div id='layer_switcher_colour' style='background-color:rgb(" + signallayer.colour + ")' /><font>Signal strength: 0 - 100</font><br /></span>");
81}
Note: See TracBrowser for help on using the repository browser.