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() {