1 | <?php
|
---|
2 |
|
---|
3 | function connectdb()
|
---|
4 | {
|
---|
5 | mysql_connect("location", "username", "password")
|
---|
6 | or die("Error connecting to mysql: " . mysql_error());
|
---|
7 | mysql_select_db('database')
|
---|
8 | or die("Error connecting to database: " . mysql_error());
|
---|
9 | }
|
---|
10 | connectdb();
|
---|
11 |
|
---|
12 | $table = 'test_1';
|
---|
13 | ?>
|
---|
14 |
|
---|
15 |
|
---|
16 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
---|
17 | <html xmlns="http://www.w3.org/1999/xhtml">
|
---|
18 | <head>
|
---|
19 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
---|
20 | <title>Heatmap</title>
|
---|
21 | <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
|
---|
22 | <script type='text/javascript' src='OpenLayers-2.10/lib/OpenLayers.js'></script>
|
---|
23 | <script src="script/heatmap.js"></script>
|
---|
24 | <script src="script/canvas-barrier.js"></script>
|
---|
25 |
|
---|
26 | <script type="text/javascript">
|
---|
27 | var map;
|
---|
28 | var vectorLayer;
|
---|
29 |
|
---|
30 | function init(){
|
---|
31 | map = new OpenLayers.Map('heatmap');
|
---|
32 |
|
---|
33 | var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
---|
34 | "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
---|
35 | map.addLayer(layer);
|
---|
36 |
|
---|
37 | map.setCenter(new OpenLayers.LonLat(4.492321,52.164898), 10);
|
---|
38 |
|
---|
39 | vectorLayer = new OpenLayers.Layer.Vector.HeatMap("HeatMap", {
|
---|
40 | rendererOptions: {
|
---|
41 | // a radius of 20px looks good at this zoom-level
|
---|
42 | pointSize: 20 ,
|
---|
43 | heatMapWebWorkerPath: "../script/heatmap-webworker.js"
|
---|
44 |
|
---|
45 | }
|
---|
46 | });
|
---|
47 |
|
---|
48 | // create a few random points
|
---|
49 | var points = [];
|
---|
50 |
|
---|
51 | <?php
|
---|
52 | $result=mysql_query("SELECT longitude, latitude FROM ".$table." LIMIT 100");
|
---|
53 | while($row=mysql_fetch_array($result))
|
---|
54 | {
|
---|
55 | echo "var point = new OpenLayers.Geometry.Point(".$row['longitude'].", ".$row['latitude'].");";
|
---|
56 | echo "var pointFeature = new OpenLayers.Feature.Vector(point);";
|
---|
57 | echo "points.push(pointFeature);";
|
---|
58 | }
|
---|
59 | ?>
|
---|
60 |
|
---|
61 | vectorLayer.addFeatures(points);
|
---|
62 |
|
---|
63 | vectorLayer.events.register("renderProgress", null, function(event) {
|
---|
64 | document.getElementById("progressBar").value = event.progress;
|
---|
65 | document.getElementById("progressBarFallback").innerHTML = event.progress;
|
---|
66 | });
|
---|
67 |
|
---|
68 |
|
---|
69 | map.addLayer(vectorLayer);
|
---|
70 | }
|
---|
71 |
|
---|
72 | function randomPoint() {
|
---|
73 | var x = random(20, 480);
|
---|
74 | var y = random(15, 240);
|
---|
75 | var lonlat = map.getLonLatFromPixel(new OpenLayers.Pixel(x, y));
|
---|
76 |
|
---|
77 | return new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
|
---|
78 | };
|
---|
79 |
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 | function toggleUseWebWorkers() {
|
---|
84 | vectorLayer.renderer.renderAsync = document.getElementById("useWebWorkers").checked;
|
---|
85 | }
|
---|
86 |
|
---|
87 | </script>
|
---|
88 | </head>
|
---|
89 |
|
---|
90 | <body onload="init()">
|
---|
91 | <div id="wrapper">
|
---|
92 | <div id="header">
|
---|
93 | <a href="index.html"><img src="img/logo.png" border="0" style="float: left;"/></a>
|
---|
94 | <font style="font-size:24px; color:white;">Stichting Wireless Leiden</font><br />
|
---|
95 | <font style="font-size:46px; color:white;">Heatmap</font>
|
---|
96 | </div>
|
---|
97 | <div id="content">
|
---|
98 | <h1>Info</h1><br />
|
---|
99 | OpenLayers heatmap. Kan traag zijn met laden.
|
---|
100 | Werkt misschien niet even goed met elke browser.<br />
|
---|
101 | Query staat op LIMIT 100 om overload te voorkomen.
|
---|
102 | </div>
|
---|
103 | <div id="heatmap">
|
---|
104 | </div>
|
---|
105 | <div id="footer"> <a href="http://www.wirelessleiden.nl/">wirelessleiden.nl</a> </div>
|
---|
106 |
|
---|
107 |
|
---|
108 | </body>
|
---|
109 | </html>
|
---|