1 | var map;
|
---|
2 | function init(){
|
---|
3 |
|
---|
4 | var projection_wgs = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
|
---|
5 |
|
---|
6 | map = new OpenLayers.Map('heatmap', {
|
---|
7 | controls: [
|
---|
8 | new OpenLayers.Control.Navigation(),
|
---|
9 | new OpenLayers.Control.PanZoomBar(),
|
---|
10 | new OpenLayers.Control.ScaleLine(),
|
---|
11 | new OpenLayers.Control.LayerSwitcher(),
|
---|
12 | new OpenLayers.Control.MousePosition({ 'displayProjection' : projection_wgs }),
|
---|
13 | ],
|
---|
14 | maxExtent: new OpenLayers.Bounds(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892),
|
---|
15 | numZoomLevels:16,
|
---|
16 | maxResolution:156543.0339,
|
---|
17 | units:'m',
|
---|
18 | projection: "EPSG:900913",
|
---|
19 | displayProjection: new OpenLayers.Projection("EPSG:4326")
|
---|
20 | });
|
---|
21 |
|
---|
22 | map.events.register('click', map, GetMousePos);
|
---|
23 | function GetMousePos(pos) {
|
---|
24 | var pix = map.getLonLatFromPixel(new OpenLayers.Pixel(pos.xy.x,pos.xy.y));
|
---|
25 | var mousepos = OpenLayers.Layer.SphericalMercator.inverseMercator(pix.lon, pix.lat);
|
---|
26 | var zoomlevel = map.getZoom();
|
---|
27 | getNodeList(zoom, mousepos);
|
---|
28 | }
|
---|
29 |
|
---|
30 | layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
|
---|
31 | map.addLayer(layerMapnik);
|
---|
32 |
|
---|
33 | layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: true});
|
---|
34 | map.addLayer(layerHeatmap2);
|
---|
35 |
|
---|
36 | layerHeatmap3 = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Only", {isBaseLayer: false, visibility: true});
|
---|
37 | map.addLayer(layerHeatmap3);
|
---|
38 |
|
---|
39 | layerHeatmap = new OpenLayers.Layer.OSM.Overlay1("Original Heatmap generator", {isBaseLayer: false, visibility: false});
|
---|
40 | map.addLayer(layerHeatmap);
|
---|
41 |
|
---|
42 | var lon = 4.48319;
|
---|
43 | var lat = 52.14068;
|
---|
44 | var zoom = 16;
|
---|
45 |
|
---|
46 | var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
|
---|
47 | map.setCenter (lonLat, zoom);
|
---|
48 | }
|
---|
49 |
|
---|
50 | function getNodeList(zoomlevel, mousepos){
|
---|
51 | var nodelist;
|
---|
52 | if (window.XMLHttpRequest){
|
---|
53 | // code for IE7+, Firefox, Chrome, Opera, Safari
|
---|
54 | nodelist=new XMLHttpRequest();
|
---|
55 | }
|
---|
56 | else{
|
---|
57 | // code for IE6, IE5
|
---|
58 | nodelist=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
59 | }
|
---|
60 |
|
---|
61 | nodelist.onreadystatechange=function(){
|
---|
62 | if (nodelist.readyState==4 && nodelist.status==200){
|
---|
63 | json=eval('(' + nodelist.responseText + ')');
|
---|
64 | var list = '<br>';
|
---|
65 | for (var i=0; i<json.length; i++){
|
---|
66 | list += json[i].fields.ssid + '<br>';
|
---|
67 | }
|
---|
68 | document.getElementById('filters').innerHTML=list;
|
---|
69 | }
|
---|
70 | }
|
---|
71 | nodelist.open("GET","/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon,true);
|
---|
72 | nodelist.send();
|
---|
73 | }
|
---|
74 |
|
---|
75 | var apid = 1;
|
---|
76 |
|
---|
77 | function filters(){
|
---|
78 | var filter;
|
---|
79 | if (window.XMLHttpRequest){
|
---|
80 | // code for IE7+, Firefox, Chrome, Opera, Safari
|
---|
81 | filter=new XMLHttpRequest();
|
---|
82 | }
|
---|
83 | else{
|
---|
84 | // code for IE6, IE5
|
---|
85 | filter=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
86 | }
|
---|
87 |
|
---|
88 | filter.onreadystatechange=function(){
|
---|
89 | if (filter.readyState==4 && filter.status==200){
|
---|
90 | map.addLayer(layerHeatmap3);
|
---|
91 | }
|
---|
92 | }
|
---|
93 | var apid = encodeURIComponent(document.getElementById("apid").value);
|
---|
94 | addFilter(apid);
|
---|
95 | }
|
---|
96 |
|
---|
97 | function addFilter(apid){
|
---|
98 | OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
---|
99 | initialize: function(name, options) {
|
---|
100 | var url = [
|
---|
101 | "/website/tile/${z}/${x},${y}.png?colour=0,0,255&accespoint__id=" + apid
|
---|
102 | ];
|
---|
103 | options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
|
---|
104 | var newArguments = [name, url, options];
|
---|
105 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
---|
106 | },
|
---|
107 | CLASS_NAME: "OpenLayers.Layer.Overlay"
|
---|
108 | });
|
---|
109 |
|
---|
110 | testlayer = new OpenLayers.Layer.OSM.Overlay("addFilter layer", {isBaseLayer: false, visibility: true});
|
---|
111 | map.addLayer(testlayer);
|
---|
112 | }
|
---|