diff --git a/access.php b/access.php
index 7d0e897..93fd0d4 100644
--- a/access.php
+++ b/access.php
@@ -20,32 +20,51 @@ $sql = "SELECT ts, lat, lon FROM tracker WHERE device='" . mysqli_real_escape_st
$result = $conn->query($sql);
if ($result->num_rows > 0) {
- header('Content-Type: application/vnd.google-earth.kml+xml');
- header('Content-Disposition: attachment; filename="export.kml"');
- echo '
-
-
-
-
- #style
- 1a1ac94e
- #ffff00
- 0.4980392156862745
- 4
- #00ff00
- 0.4980392156862745
-
-
-
+ header('Content-Type: application/vnd.geo+json');
+ header('Content-Disposition: attachment; filename="export.geojson"');
+ $output = '{
+ "type": "FeatureCollection",
+ "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
+ "features": [
+ { "type": "Feature",
+ "properties": {
+ "Name": null,
+ "description": null,
+ "timestamp": null,
+ "begin": null,
+ "end": null,
+ "altitudeMode": null,
+ "tessellate": -1,
+ "extrude": 0,
+ "visibility": -1,
+ "drawOrder": null,
+ "icon": null,
+ "styleUrl": "#style",
+ "styleHash": "1a1ac94e",
+ "stroke": "#ffff00",
+ "stroke_opacity": "0.4980392156862745",
+ "stroke_width": "4",
+ "fill": "#00ff00",
+ "fill_opacity": "0.4980392156862745"
+ },
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [
';
while($row = $result->fetch_assoc()) {
- echo $row["lon"] . "," . $row["lat"] . "\n";
+ $output .= " [ " . $row["lon"] . ", " . $row["lat"] . " ],\n";
}
- echo '
-
-';
+ $output = substr_replace($output, "", strrpos($output, ","), 1);
+
+ $output .= ' ]
+ }
+ }
+ ]
+}';
+
+ echo $output;
} else {
die("No records found.");
diff --git a/day.php b/day.php
index bb4494e..48766aa 100644
--- a/day.php
+++ b/day.php
@@ -20,32 +20,51 @@ $sql = "SELECT ts, lat, lon FROM tracker WHERE device='" . mysqli_real_escape_st
$result = $conn->query($sql);
if ($result->num_rows > 0) {
- header('Content-Type: application/vnd.google-earth.kml+xml');
- header('Content-Disposition: attachment; filename="export.kml"');
- echo '
-
-
-
-
- #style
- 1a1ac94e
- #ffff00
- 0.4980392156862745
- 4
- #00ff00
- 0.4980392156862745
-
-
-
+ header('Content-Type: application/vnd.geo+json');
+ header('Content-Disposition: attachment; filename="export.geojson"');
+ $output = '{
+ "type": "FeatureCollection",
+ "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
+ "features": [
+ { "type": "Feature",
+ "properties": {
+ "Name": null,
+ "description": null,
+ "timestamp": null,
+ "begin": null,
+ "end": null,
+ "altitudeMode": null,
+ "tessellate": -1,
+ "extrude": 0,
+ "visibility": -1,
+ "drawOrder": null,
+ "icon": null,
+ "styleUrl": "#style",
+ "styleHash": "1a1ac94e",
+ "stroke": "#ffff00",
+ "stroke_opacity": "0.4980392156862745",
+ "stroke_width": "4",
+ "fill": "#00ff00",
+ "fill_opacity": "0.4980392156862745"
+ },
+ "geometry": {
+ "type": "LineString",
+ "coordinates": [
';
while($row = $result->fetch_assoc()) {
- echo $row["lon"] . "," . $row["lat"] . "\n";
+ $output .= " [ " . $row["lon"] . ", " . $row["lat"] . " ],\n";
}
- echo '
-
-';
+ $output = substr_replace($output, "", strrpos($output, ","), 1);
+
+ $output .= ' ]
+ }
+ }
+ ]
+}';
+
+ echo $output;
} else {
die("No records found.");