forked from econpy/torque
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapdata.php
36 lines (32 loc) · 1.08 KB
/
mapdata.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require("./creds.php");
// Connect to Database
mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
// Get Latitude/Longitude data from MySQL
$geoqry = mysql_query("SELECT kff1006, kff1005
FROM $db_table
ORDER BY time DESC
LIMIT 5000") or die(mysql_error());
$latlong = array();
while($geo = mysql_fetch_array($geoqry)) {
if (($geo["0"] != 0) && ($geo["1"] != 0)) {
$latlong[] = array("latitude" => $geo["0"], "longitude" => $geo["1"]);
}
}
// Create array of Latitude/Longitude strings in Google Maps JavaScript format
$mapdata = array();
foreach($latlong as $d) {
$mapdata[] = "new google.maps.LatLng(" . $d['latitude'] . ", " . $d['longitude'] . ")";
}
$imapdata = implode(",\n ", $mapdata);
// Centering location for the map is the most recent location
if (isset($latlong[0])) {
$centerlat = $latlong[0]["latitude"];
$centerlong = $latlong[0]["longitude"];
}
else {
$centerlat = 38.5;
$centerlong = -98;
}
?>