This repository was archived by the owner on Mar 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
218 lines (170 loc) · 6.46 KB
/
index.php
File metadata and controls
218 lines (170 loc) · 6.46 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
////////////////////////////////////////////////////////////////
//
// index.php
// The main plotting file for spot-tracker
//
////////////////////////////////////////////////////////////////
// Start with the most important stuff - import all the code that does stuff!
include('includes/includes.php');
// Check what tag is being requested. If there is no tag defined, or it's blank show everything
if (isset($_GET['tag']) && $_GET['tag'] != "" && $_GET['tag'] != "All") {
$tag = $_GET['tag'];
$plotline = "1";
} else {
$tag = "%";
$plotline = "0";
}
// Main query to return all points for a given tag (in time ascending order)
$result = cachedSQL("SELECT * FROM `".$unitname."` WHERE tag LIKE \"".$tag."\" order BY time ASC");
// Get the total number of points - used to various things
$num_rows = mysql_num_rows($result);
// Bail out if there is nothing to plot! (This shouldn't happen now as the default is "All").
if (!mysql_num_rows($result)) {
showniceerror("No data returned from the database!");
}
// Colour gradient settings. (start_hex_colour, finish_hex_colour, number_of_points)
$gradient=gradient($gradstart,$gradend,$num_rows);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" style="height:100%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="style/map.css" type="text/css" media="screen" />
<title><?php echo $sitetitle; ?></title>
<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $gmapsapi; ?>" type="text/javascript"></script>
<script src="javascript/mapiconmaker.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var mmap = new GMap2(document.getElementById("map"));
mmap.setCenter(new GLatLng(0,0),2);
var bounds = new GLatLngBounds();
mmap.setMapType(G_PHYSICAL_MAP);
mmap.addControl(new GScaleControl());
mmap.addControl(new GLargeMapControl());
mmap.addControl(new GMenuMapTypeControl());
mmap.addMapType(G_PHYSICAL_MAP) ;
mmap.enableScrollWheelZoom();
<?php
//
// Start a counter for each point
$count=0;
// Start the MySQL fetch
while($row = mysql_fetch_array($result)) {
// Image Points
if ($row['img']!="") {
$map_javascript .= "\nvar newIcon".$count." = MapIconMaker.createMarkerIcon(".
"{width: ".$iconsize.", height: ".$iconsize.", primaryColor: \"#".$photocolour."\"});\n";
// Last Point
} elseif ($count==$num_rows-1) {
$map_javascript .= "\nvar newIcon".$count." = MapIconMaker.createMarkerIcon(".
"{width: ".$iconsize.", height: ".$iconsize.", primaryColor: \"#".$gradient[$count]."\"});\n";
// First Point
} elseif ($count=="0") {
$map_javascript .= "\nvar newIcon".$count." = MapIconMaker.createMarkerIcon(".
"{width: ".$iconsize.", height: ".$iconsize.", primaryColor: \"#".$gradient[$count]."\"});\n";
// Other Points
} else {
$map_javascript .= "\nvar newIcon".$count." = MapIconMaker.createMarkerIcon(".
"{width: ".$iconsize.", height: ".$iconsize.", primaryColor: \"#".$gradient[$count]."\"});\n";
}
$map_javascript .= "var position".$count." = new GLatLng(".$row['lat'].", ".$row['lng'].");\n";
$map_javascript .= "var marker".$count." = new GMarker(position".$count.", {icon: newIcon".$count."});\n";
$map_javascript .= "mmap.addOverlay(marker".$count.");\n";
$map_javascript .= "bounds.extend(position".$count.");\n\n";
$map_javascript .= "marker".$count.".bindInfoWindowHtml('<div class=\"pointbox\">";
// Check if there's an image to display for that point
if ($row['img']!="") {
$map_javascript .= "<img src=\"".$row['img']."\"><br>";
}
// Print the message, location details and time
$map_javascript .= "<center><b>Msg: </b>".
$row['type'].
" <b>Time: </b>"
.date("jS F Y, g:i a T", $row['time']).
"<br><b>Lat:</b> ".
round($row['lat'],3).
" <b>Long:</b> ".
round($row['lng'],3).
"<br><b>Tag:</b> ".
$row['tag'];
if ($row['notes'] != "") {
$map_javascript .= "<br><b>Notes:</b> ".
$row['notes'];
}
$map_javascript .= "</div></center>');
";
$line_javascript .= "new GLatLng(".$row['lat'].", ".$row['lng']."),\n";
// Increment count for the next point to plot
$count=$count+1;
// End MySQL fetch while loop
}
// Print all the map rendering javascript created in the while loop above
echo $map_javascript;
/////////////////////////////////////////
//
// Start of the connected-line plotting
//
////////////////////////////////////////
// If plotline is enabled, connect the points
if ($plotline == 1) {
$line_javascript = "\n\nvar polyline = new GPolyline([\n" . $line_javascript;
$line_javascript .= "], \"#FF0000\", 3);\n";
$line_javascript .= "mmap.addOverlay(polyline);\n\n";
echo $line_javascript;
}
// Determine the zoom level from the bounds
echo "\nmmap.setZoom(mmap.getBoundsZoomLevel(bounds));\n";
// Determine the centre from the bounds
echo "mmap.setCenter(bounds.getCenter());\n";
?>
}
}
</script>
</head>
<body style="height:100%;margin:0" onload="load()">
<div id="map" style="width: 100%; height: 100%;"></div>
<div id="dropbox"></div>
<div id="title"><?php echo $sitetitle;?></div>
<div id="box2"><?php echo $subtitle;?></div>
<div id="legend">
<img src="images/icon-red.png"><br>SPOT<br>
<img src="images/icon-yellow.png"><br>SPOT with Photo
</div>
<div id="box1">
<form id="tagbox" action="index.php" method="get">
Tag:
<select name="tag" onChange="this.form.submit()">
<?php
/////////////////////////////////////////////////////////////////
//
// Get the list of all the tags and display in the drop down box
//
/////////////////////////////////////////////////////////////////
$tagresult = cachedSQL("SELECT DISTINCT tag FROM `".$unitname."`");
while($tagrow = mysql_fetch_array($tagresult)) {
if ($tagrow['tag']==$tag && $tag != "All") {
echo "<option selected>".
$tagrow['tag'].
"</option>\n";
} else {
echo "<option>".
$tagrow['tag'].
"</option>\n";
}
}
// If the tag is set to "All" or to nothing, make All the selection option
if ($tag == "All" || $tag == "%") {
echo "<option selected>All</option>";
} else {
echo "<option>All</option>";
}
?>
</select>
</form>
</div>
</body>
</html>