[openstreetmap/openstreetmap-website] Added 'Reverse Directions' link (#1693)
Tom Hughes
notifications at github.com
Sun Dec 3 16:04:28 UTC 2017
tomhughes requested changes 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 think it would be better to do this in the same way we do it in other places, along these lines:
```
OSM.router.route("/directions?" + querystring.stringify({
from: $("#route_to").val(),
to: $("#route_from").val()
}));
```
--
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#pullrequestreview-80705272
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20171203/acd77d9e/attachment.html>
More information about the rails-dev
mailing list