[openstreetmap/openstreetmap-website] Added 'Reverse Directions' link (#1693)
Jamie Guthrie
notifications at github.com
Sun Dec 3 18:55:59 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");
+ });
Basically .val() forces through an Geolocation API call which can mess with the actual user-submitted value or coord
--
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_r154533093
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20171203/764a62db/attachment.html>
More information about the rails-dev
mailing list