X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c47cb299a842a2eb7d022fcf4f0d02c08001f928..51a2d85053b67b2bc842fa45ac8eb998f8585add:/app/assets/javascripts/index/directions.js diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 2338f537f..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); @@ -73,8 +75,8 @@ OSM.Directions = function (map) { $(".directions_form .btn-close").on("click", function (e) { e.preventDefault(); - $(".describe_location").toggle(!endpoints[0].value); - $(".search_form input[name='query']").val(endpoints[0].value); + $(".describe_location").toggle(!endpoints[1].value); + $(".search_form input[name='query']").val(endpoints[1].value); OSM.router.route("/" + OSM.formatHash(map)); }); @@ -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 }) + "
");