diff --git a/background.js b/background.js
index 6c7dc24..e60dbe0 100644
--- a/background.js
+++ b/background.js
@@ -84,7 +84,12 @@ function trackTitle(geoJson) {
* @returns Simple gpx string.
*/
function toGpx(geoJson) {
- const route = geoJson.segments[0].geom;
+ let trackSegments = geoJson.segments.map(segment => {
+ return `
+ ${segment.geom.coordinates.map(toTrackPoint).join("")}
+ `;
+ }).join("");
+
const routeTitle = trackTitle(geoJson);
const xmlString = `
@@ -98,9 +103,7 @@ function toGpx(geoJson) {
${toWayPoint(geoJson.destination_poi)}
Track ${routeTitle}
-
- ${route.coordinates.map(toTrackPoint).join("")}
-
+ ${trackSegments}
`;
diff --git a/manifest.json b/manifest.json
index c63b54c..5dbcacf 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "SAC Route Portal GPX Downloader",
- "version": "0.3",
+ "version": "0.4",
"developer": {
"name": "Sebastian Hugentobler",
"url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"