[openstreetmap/openstreetmap-website] Added 'Reverse Directions' link (#1693)

Jamie Guthrie notifications at github.com
Sun Dec 3 18:55:09 UTC 2017


jguthrie100 commented on this pull request.



> @@ -111,6 +113,20 @@ OSM.Directions = function (map) {
     return endpoint;
   }
 
+  $(".directions_form .reverse_directions").on("click", function() {
+    var input_from = endpoints[0].input.val();
+    var input_to = endpoints[1].input.val();
+    var latlng_from = endpoints[0].latlng;
+    var latlng_to = endpoints[1].latlng;
+
+    endpoints[0].setLatLng(latlng_to);
+    endpoints[1].setLatLng(latlng_from);
+    endpoints[0].input.val(input_to);
+    endpoints[1].input.val(input_from);
+
+    $(".directions_form .routing_go").trigger("click");
+  });

I originally did it that way, but it doesn't work when you paste a link with just coords in the to and from inputs.

It also jumps the marker to the nearest feature, rather than keeping it pin pointed in the exact coordinate (which leads to the problem OP mentioned about the true coord location not being retained). I'm not sure if it's just standard OSM behaviour to jump the marker to the nearest feature though.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/1693#discussion_r154533072
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20171203/d1662932/attachment.html>


More information about the rails-dev mailing list