From: Holger Jeromin Date: Sun, 26 Jan 2020 10:01:45 +0000 (+0100) Subject: Prevent exceptions while reversing directions X-Git-Tag: live~2847^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a32f4c231e678dd02a4728355455547d3d20fe2a Prevent exceptions while reversing directions --- diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 4c39d6781..5f822b472 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -142,12 +142,20 @@ OSM.Directions = function (map) { $(".directions_form .reverse_directions").on("click", function () { var from = endpoints[0].latlng, - to = endpoints[1].latlng; + to = endpoints[1].latlng, + routeFrom = "", + routeTo = ""; + if(from){ + routeFrom = from.lat + "," + from.lng; + } + if(to){ + routeTo = to.lat + "," + to.lng; + } OSM.router.route("/directions?" + querystring.stringify({ from: $("#route_to").val(), to: $("#route_from").val(), - route: to.lat + "," + to.lng + ";" + from.lat + "," + from.lng + route: routeTo + ";" + routeFrom })); });