summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'index.html')
-rw-r--r--index.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..ce9f4fa
--- /dev/null
+++ b/index.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Calimoto GPX (rtept) to Google Maps Directions - Fixed Start/End</title>
+ <style>
+ body { font-family: Arial, sans-serif; margin: 2em; }
+ input[type="file"] { margin-bottom: 1em; }
+ #result { margin-top: 1em; }
+ a { word-break: break-word; }
+ </style>
+</head>
+<body>
+
+<h1>Calimoto GPX (rtept) to Google Maps Directions (Fixed Start/End Point)</h1>
+
+<input type="file" id="gpxfile" accept=".gpx" />
+<div id="result"></div>
+
+<script>
+document.getElementById('gpxfile').addEventListener('change', function(event) {
+ const file = event.target.files[0];
+ if (!file) return;
+
+ // Define your new fixed start/end point
+ const startLat = 46.962153; // Your new latitude
+ const startLon = 7.446944; // Your new longitude
+ const startPoint = `${startLat},${startLon}`;
+
+ const reader = new FileReader();
+ reader.onload = function(e) {
+ const parser = new DOMParser();
+ const xmlDoc = parser.parseFromString(e.target.result, "application/xml");
+
+ const routePoints = xmlDoc.getElementsByTagName('rtept');
+ if (routePoints.length < 3) {
+ document.getElementById('result').innerHTML = "Not enough <rtept> points in this file.";
+ return;
+ }
+
+ const coords = [];
+ // Skip first and last points
+ for (let i = 1; i < routePoints.length - 1; i++) {
+ const lat = routePoints[i].getAttribute('lat');
+ const lon = routePoints[i].getAttribute('lon');
+ coords.push(lat + "," + lon);
+ }
+
+ const MAX_WAYPOINTS = 23; // Google Maps limit: start + waypoints + end
+
+ let selectedCoords = [];
+ if (coords.length <= (MAX_WAYPOINTS - 2)) {
+ selectedCoords = coords;
+ } else {
+ // Shrink points smartly
+ const intermediatePoints = MAX_WAYPOINTS - 2; // 1 for start, 1 for end
+ const interval = coords.length / intermediatePoints;
+ for (let i = 1; i < intermediatePoints - 1; i++) {
+ const index = Math.round(i * interval);
+ if (index >= coords.length) break;
+ selectedCoords.push(coords[index]);
+ }
+ }
+
+ // Build final path: start -> route -> end
+ const fullCoords = [startPoint, ...selectedCoords, startPoint];
+
+ const baseUrl = "https://www.google.com/maps/dir/";
+ const url = baseUrl + fullCoords.join('/');
+
+ document.getElementById('result').innerHTML = `<p><strong>Directions Link:</strong></p><p><a href="${url}" target="_blank">${url}</a></p>`;
+ };
+
+ reader.readAsText(file);
+});
+</script>
+
+</body>
+</html>