[openstreetmap/openstreetmap-website] Prevent exceptions while reversing directions (#2521)

Holger Jeromin notifications at github.com
Sun Jan 26 10:52:43 UTC 2020


HolgerJeromin commented on this pull request.



> @@ -142,12 +142,20 @@ OSM.Directions = function (map) {
 
   $(".directions_form .reverse_directions").on("click", function () {
     var from = endpoints[0].latlng,
-        to = endpoints[1].latlng;
+        to = endpoints[1].latlng,
+        routeFrom = "",
+        routeTo = "";
+    if (from) {
+      routeFrom = from.lat + "," + from.lng;
+    }
+    if (to) {
+      routeTo = to.lat + "," + to.lng;
+    }
 
     OSM.router.route("/directions?" + querystring.stringify({
       from: $("#route_to").val(),
       to: $("#route_from").val(),

Note that THESE `to` things is the property for the object of the `stringyfy` and not the variable six lines above

-- 
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/2521#pullrequestreview-348371583
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200126/d005458a/attachment.htm>


More information about the rails-dev mailing list