From b01743d9c4c8f54a4455dd62196541f07dff2065 Mon Sep 17 00:00:00 2001 From: Pedan Date: Tue, 29 Jul 2025 17:20:36 +0200 Subject: [PATCH] fixed ios export --- app/web/static/route.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/web/static/route.js b/app/web/static/route.js index 1dff78c..886dfea 100644 --- a/app/web/static/route.js +++ b/app/web/static/route.js @@ -231,15 +231,22 @@ ${latlngs.map(pt => ` `).join( `; + let blob = new Blob([gpx], {type: "application/gpx+xml"}); let url = URL.createObjectURL(blob); - let a = document.createElement('a'); - a.href = url; - a.download = "freemoto-route.gpx"; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); + + // iOS workaround: open in new tab instead of triggering download + if (navigator.userAgent.match(/(iPad|iPhone|iPod)/i)) { + window.open(url, '_blank'); + } else { + let a = document.createElement('a'); + a.href = url; + a.download = "freemoto-route.gpx"; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + } + setTimeout(() => URL.revokeObjectURL(url), 1000); } document.getElementById('exportGpxBtn').addEventListener('click', function() {