]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions.js
Go through the router when reversing directions
[rails.git] / app / assets / javascripts / index / directions.js
index 94f9bb1f018f05ca6894cede85f4cdab7b76bfee..093afe30a9148836ac63a39cd985ee2b3538ae47 100644 (file)
@@ -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;