X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/1f8a86f7bcd0974a2b3876137dd1af8e147f69af..2de26d54ef22c5653f830d0ce4938df78d0ca0fd:/app/assets/javascripts/index/directions.js diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 3d6da84fc..3d52ec9fb 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 }) + "
");