source: src/django_gheat/wlheatmap/static/heatmap.js@ 9599

Last change on this file since 9599 was 9599, checked in by rick, 13 years ago

Cleanup calling into proper function.

File size: 3.0 KB
Line 
1/**
2 * Var 'map' is set global, used in 'heatmap_extensions.js'.
3 */
4var map;
5
6function 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 new OpenLayers.Control.PanZoomBar(),
24 new OpenLayers.Control.ZoomBox(),
25 new OpenLayers.Control.OverviewMap({
26 maximized : false,
27 mapOptions: { theme: null, },
28 }),
29 new OpenLayers.Control.MousePosition({ 'displayProjection' : projection_wgs }),
30 /**
31 * Decided to disable these controls.
32 * The layerswitcher has been replaced with a custom one. If you want the original back,
33 * make sure to disable the custom one to prevent collision.
34 */
35
36 //new OpenLayers.Control.PanZoomBav(),
37 //new OpenLayers.Control.ScaleLine(),
38 //new OpenLayers.Control.LayerSwitcher(),
39 ],
40 maxExtent: new OpenLayers.Bounds(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892),
41 numZoomLevels:16,
42 maxResolution:156543.0339,
43 units:'m',
44 projection: "EPSG:900913",
45 displayProjection: new OpenLayers.Projection("EPSG:4326")
46 });
47
48 map.events.register('click', map, GetMousePos);
49 function GetMousePos(pos) {
50 var pix = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x,pos.xy.y));
51 var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(pix.lon, pix.lat);
52 var zoomlevel = map.getZoom();
53 getNodeList(zoom, mousepos);
54 }
55
56 layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
57 map.addLayer(layerMapnik);
58
59 var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
60 map.setCenter (lonLat, zoom);
61
62
63 /**
64 * Layers are created and put in switcher
65 */
66 function add_item(category, layer) {
67 map.addLayer(layer);
68 var checked = '';
69 if (layer.getVisibility()) { checked = "checked='checked'"; };
70 $("#" + category).append("<span id=\"" + layer.name + "\">" +
71 " <div id='layer_switcher_colour' style='background-color:rgb(" + layer.colour + ")' />" +
72 "<input type='checkbox' id='togglelayer' " + checked + " /><font>" + layer.name + " </font><br /></span>"
73 );
74 }
75
76 var signallayer = new OpenLayers.Layer.OSM.Overlay4("signallayer", {isBaseLayer: false, visibility: false});
77 var wlsignalLayer = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Coverage", {isBaseLayer: false, visibility: true});
78 var nodesLayer = new OpenLayers.Layer.GML.NodesOverlay("Node Locations", {isBaseLayer: false, visibility: false});
79
80 add_item('default', signallayer);
81 add_item('default', wlsignalLayer);
82 add_item('features', nodesLayer);
83}
Note: See TracBrowser for help on using the repository browser.