From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Sun, 16 Feb 2025 16:08:37 +0000 (+0100) Subject: Enable exporting direction paths X-Git-Tag: live~127^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3939f24460b6c32c25a5432764ff5f4ff5e8dea6?ds=sidebyside Enable exporting direction paths --- diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 2338f537f..c472108ae 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -36,6 +36,8 @@ OSM.Directions = function (map) { OSM.DirectionsEndpoint(map, $("input[name='route_to']"), OSM.MARKER_RED, endpointDragCallback, endpointChangeCallback) ]; + let downloadURL = null; + const expiry = new Date(); expiry.setYear(expiry.getFullYear() + 10); @@ -189,6 +191,16 @@ OSM.Directions = function (map) { turnByTurnTable.append(row); }); + const blob = new Blob([JSON.stringify(polyline.toGeoJSON())], { type: "application/json" }); + URL.revokeObjectURL(downloadURL); + downloadURL = URL.createObjectURL(blob); + + $("#sidebar_content").append(`
${ + I18n.t("javascripts.directions.download") + }
`); + $("#sidebar_content").append("" + I18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) + "
"); diff --git a/config/locales/en.yml b/config/locales/en.yml index 42669ca9e..73854320b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3312,6 +3312,8 @@ en: ninth: "9th" tenth: "10th" time: "Time" + download: "Download track as GeoJSON" + filename: "route" query: node: Node way: Way