[9302] | 1 | /**
|
---|
| 2 | * Var 'map' is set global, used in 'heatmap_extensions.js'.
|
---|
| 3 | */
|
---|
[9203] | 4 | var map;
|
---|
[9302] | 5 |
|
---|
[9570] | 6 | function init_heatmap(){
|
---|
[9269] | 7 | var lat = getURLParameter('lat');
|
---|
| 8 | var lon = getURLParameter('lon');
|
---|
| 9 | var zoom = getURLParameter('zoom');
|
---|
| 10 |
|
---|
| 11 | if(lat=='null' || lon=='null' || zoom=='null'){
|
---|
[9316] | 12 | var lat = 52.15514;
|
---|
| 13 | var lon = 4.48959;
|
---|
| 14 | var zoom = 13;
|
---|
[9269] | 15 | }
|
---|
[9264] | 16 | var projection_wgs = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
|
---|
[9139] | 17 |
|
---|
[9264] | 18 | map = new OpenLayers.Map('heatmap', {
|
---|
| 19 | controls: [
|
---|
| 20 | new OpenLayers.Control.Navigation(),
|
---|
[9302] | 21 | new OpenLayers.Control.Permalink(),
|
---|
[9546] | 22 | new OpenLayers.Control.PanZoomBar(),
|
---|
[9576] | 23 | new OpenLayers.Control.OverviewMap({ maximized : true }),
|
---|
[9302] | 24 | new OpenLayers.Control.MousePosition({ 'displayProjection' : projection_wgs }),
|
---|
| 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 |
|
---|
[9576] | 31 | //new OpenLayers.Control.PanZoomBav(),
|
---|
[9264] | 32 | //new OpenLayers.Control.ScaleLine(),
|
---|
[9276] | 33 | //new OpenLayers.Control.LayerSwitcher(),
|
---|
[9264] | 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 | });
|
---|
[9175] | 42 |
|
---|
[9264] | 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 | }
|
---|
[9175] | 50 |
|
---|
[9264] | 51 | layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
|
---|
| 52 | map.addLayer(layerMapnik);
|
---|
[9147] | 53 |
|
---|
[9400] | 54 | layerHeatmap2 = new OpenLayers.Layer.OSM.Overlay2("All Access points", {isBaseLayer: false, visibility: false});
|
---|
[9570] | 55 | //map.addLayer(layerHeatmap2);
|
---|
[9166] | 56 |
|
---|
[9570] | 57 | signallayer = new OpenLayers.Layer.OSM.Overlay4("signallayer", {isBaseLayer: false, visibility: false});
|
---|
| 58 | map.addLayer(signallayer);
|
---|
| 59 |
|
---|
[9264] | 60 | layerHeatmap3 = new OpenLayers.Layer.OSM.Overlay3("Wireless Leiden Only", {isBaseLayer: false, visibility: true});
|
---|
| 61 | map.addLayer(layerHeatmap3);
|
---|
[9190] | 62 |
|
---|
[9549] | 63 | layerHeatmap = new OpenLayers.Layer.OSM.Overlay1("Original Heatmap generator", {isBaseLayer: false, visibility: false});
|
---|
[9570] | 64 | //map.addLayer(layerHeatmap);
|
---|
[9139] | 65 |
|
---|
[9264] | 66 | var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
|
---|
| 67 | map.setCenter (lonLat, zoom);
|
---|
[9274] | 68 |
|
---|
| 69 |
|
---|
[9302] | 70 | /**
|
---|
| 71 | * Layers above are put in switcher, category 'default', with code below.
|
---|
| 72 | * TODO: Make process for putting layers into layerswitcher dynamic instead of putting every layer there manually.
|
---|
| 73 | */
|
---|
| 74 |
|
---|
[9570] | 75 | //$("#default").append("<span id=\"" + layerHeatmap.name + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap.colour + ")' /><input type=checkbox id=togglelayer /><font>" + layerHeatmap.name + " </font><br /></span>");
|
---|
[9274] | 76 |
|
---|
[9570] | 77 | //$("#default").append("<span id=\"" + layerHeatmap2.name + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap2.colour + ")' /><input type=checkbox id=togglelayer /><font>" + layerHeatmap2.name + " </font><br /></span>");
|
---|
[9274] | 78 |
|
---|
[9575] | 79 | $("#default").append("<span id=\"" + signallayer.name + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + signallayer.colour + ")' /><input type=checkbox id=togglelayer /><font>Replaced during init</font><br /></span>");
|
---|
[9570] | 80 |
|
---|
[9406] | 81 | $("#default").append("<span id=\"" + layerHeatmap3.name + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + layerHeatmap3.colour + ")' /><input type=checkbox id=togglelayer checked/><font>" + layerHeatmap3.name + " </font><br /></span>");
|
---|
[9274] | 82 |
|
---|
[9139] | 83 | }
|
---|