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

Last change on this file since 9190 was 9190, checked in by rick, 14 years ago

I might be a bit biased, feel free to revert. But disable the original heatmap
generator by default.

File size: 2.4 KB
Line 
1function init(){
2
3 var projection_wgs = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
4
5 map = new OpenLayers.Map('heatmap', {
6 controls: [
7 new OpenLayers.Control.Navigation(),
8 new OpenLayers.Control.PanZoomBar(),
9 new OpenLayers.Control.ScaleLine(),
10 new OpenLayers.Control.LayerSwitcher(),
11 new OpenLayers.Control.MousePosition({ 'displayProjection' : projection_wgs }),
12 ],
13 maxExtent: new OpenLayers.Bounds(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892),
14 numZoomLevels:16,
15 maxResolution:156543.0339,
16 units:'m',
17 projection: "EPSG:900913",
18 displayProjection: new OpenLayers.Projection("EPSG:4326")
19 });
20
21 map.events.register('click', map, GetMousePos);
22 function GetMousePos(pos) {
23 var pixbuffer = 100;
24 var sw = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x+pixbuffer,pos.xy.y-pixbuffer));
25 var ne = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x-pixbuffer,pos.xy.y+pixbuffer));
26 var pointsw = OpenLayers.Layer.SphericalMercator.inverseMercator(sw.lon, sw.lat);
27 var pointne = OpenLayers.Layer.SphericalMercator.inverseMercator(ne.lon, ne.lat);
28 getNodeList(pointsw, pointne);
29 }
30
31 layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
32 map.addLayer(layerMapnik);
33
34 layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: true});
35 map.addLayer(layerHeatmap2);
36
37 layerHeatmap3 = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Only", {isBaseLayer: false, visibility: true});
38 map.addLayer(layerHeatmap3);
39
40 layerHeatmap = new OpenLayers.Layer.OSM.Overlay1("Original Heatmap generator", {isBaseLayer: false, visibility: false});
41 map.addLayer(layerHeatmap);
42
43 var lon = 4.48907;
44 var lat = 52.158431;
45 var zoom = 16;
46
47 var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
48 map.setCenter (lonLat, zoom);
49}
50
51function getNodeList(sw, ne){
52 var nodelist;
53 if (window.XMLHttpRequest){
54 // code for IE7+, Firefox, Chrome, Opera, Safari
55 nodelist=new XMLHttpRequest();
56 }
57 else{
58 // code for IE6, IE5
59 nodelist=new ActiveXObject("Microsoft.XMLHTTP");
60 }
61
62 nodelist.onreadystatechange=function(){
63 if (nodelist.readyState==4 && nodelist.status==200){
64 txt=nodelist.responseText
65 document.getElementById('nodelist').innerHTML=txt;
66 }
67 }
68
69 nodelist.open("GET","/website/nodelist/" + sw.lat + "," + sw.lon + "," + ne.lat + "," + ne.lon,true);
70 nodelist.send();
71}
Note: See TracBrowser for help on using the repository browser.