]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions.js
Load pluralizers
[rails.git] / app / assets / javascripts / index / directions.js
index 97fa961d6993f141addd4718fef24839a9fbec66..40ca85d960fc6f0d29504761a1bb8eeb2b4ab581 100644 (file)
@@ -273,13 +273,15 @@ OSM.Directions = function (map) {
     map.fire("startinglocation", { latlng: [lat, lng] });
   }
 
+  function startingLocationListener({ latlng }) {
+    if (endpoints[0].value) return;
+    endpoints[0].setValue(latlng.join(", "));
+  }
+
   map.on("locationfound", ({ latlng: { lat, lng } }) =>
     lastLocation = [lat, lng]
   ).on("locateactivate", () => {
-    map.once("startinglocation", ({ latlng }) => {
-      if (endpoints[0].value) return;
-      endpoints[0].setValue(latlng.join(", "));
-    });
+    map.once("startinglocation", startingLocationListener);
   });
 
   const page = {};