X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/61faea262a5b75ddca7035daa68239a1f0c54d05..45e560bef6ecc7702597ce04c781a59bb688ebc4:/app/assets/javascripts/index/directions.js?ds=sidebyside diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 4c39d6781..5f9027ec6 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -141,13 +141,21 @@ OSM.Directions = function (map) { } $(".directions_form .reverse_directions").on("click", function () { - var from = endpoints[0].latlng, - to = endpoints[1].latlng; + var coordFrom = endpoints[0].latlng, + coordTo = endpoints[1].latlng, + routeFrom = "", + routeTo = ""; + if (coordFrom) { + routeFrom = coordFrom.lat + "," + coordFrom.lng; + } + if (coordTo) { + routeTo = coordTo.lat + "," + coordTo.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 })); });