X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/5f35d37fee5a24a0f69ba375531e314eda85b573..aea57cdfc321edd68467e0b17bc5335f84a512b9:/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 bb835f2fb..093afe30a 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -76,7 +76,7 @@ OSM.Directions = function (map) { endpoint.awaitingGeocode = true; - $.getJSON(document.location.protocol + OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) { + $.getJSON(OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) { endpoint.awaitingGeocode = false; endpoint.hasGeocode = true; if (json.length === 0) { @@ -111,6 +111,17 @@ OSM.Directions = function (map) { return endpoint; } + $(".directions_form .reverse_directions").on("click", function() { + var from = endpoints[0].latlng, + to = endpoints[1].latlng; + + OSM.router.route("/directions?" + querystring.stringify({ + from: $("#route_to").val(), + to: $("#route_from").val(), + route: from.lat + "," + from.lng + ";" + to.lat + "," + to.lng + })); + }); + $(".directions_form .close").on("click", function(e) { e.preventDefault(); var route_from = endpoints[0].value;