-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.php
More file actions
148 lines (117 loc) · 3.64 KB
/
index.php
File metadata and controls
148 lines (117 loc) · 3.64 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
function random_color()
{
mt_srand((double)microtime()*1000000);
$c = '';
while(strlen($c) < 6) $c .= sprintf("%02X", mt_rand(0, 255));
return $c;
}
$trackColor = "#000000";
$randomColors = false;
if(isset($_GET["color"]))
{
switch($_GET["color"])
{
case 'black': $trackColor = "#000000"; break;
case 'red': $trackColor = "#FF0000"; break;
case 'yellow': $trackColor = "#FFFF00"; break;
case 'green': $trackColor = "#00FF00"; break;
case 'random':
$trackColor = "random";
$randomColors = true;
break;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bike Ride Tracking</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="distribution" content="global">
<meta name="robots" content="none">
<meta name="language" content="en">
<meta name="description" content="">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen">
<script src="http://maps.google.com/maps?file=api&v=2&key=YOUR_GOOGLE_MAPS_API_KEY" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load()
{
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl ());
map.setCenter(new GLatLng(43.648795,-79.403687), 14); // Defaults to downtown Toronto Ontario.
map.setMapType(G_HYBRID_MAP);
map.enableRotation();
<?php
$myDirectory = opendir("./gpx");
while($entryName = readdir($myDirectory)) $dirArray[] = $entryName;
closedir($myDirectory);
$indexCount = count($dirArray);
for($index = 0; $index < $indexCount; $index++)
{
if($randomColors) $trackColor = "#" . random_color();
$filename = $dirArray[$index];
if($filename != ".." && $filename != ".")
{
echo '
GDownloadUrl("gpx/' . $filename . '", function(data, responseCode)
{
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("trkpt");
var data = new Array();
for (var i = 0; i < markers.length; i++)
{
var lat = parseFloat(markers[i].getAttribute("lat"));
var lon = parseFloat(markers[i].getAttribute("lon"))
if (lat != null && lon != null)
{
var point = new GLatLng(lat, lon);
data[i] = point;
}
}
var polyline = new GPolyline(data, "' . $trackColor . '", 5);
map.addOverlay(polyline);
});
';
}
}
?>
}
$("#toolbar").draggable();
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="toolbar">
<h3>Bike Ride Tracking</h3>
<p>Bike Trips Tracked: <?php echo $indexCount - 2; ?></p>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
Track Colour:
</td>
<td>
<form name="colorForm" action="index.php" method="GET">
<div align="center">
<select name="color" onchange="this.form.submit();">
<option value="">Select a Colour</option>
<option value="black">Black</option>
<option value="red">Red</option>
<option value="yellow">Yellow</option>
<option value="green">Green</option>
<option value="random">Random</option>
</select>
</div>
</form>
</td>
</tr>
</table>
</div>
<div id="map" style="width:100%; height:100%"></div>
</body>
</html>