]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5737'
authorTom Hughes <tom@compton.nu>
Sat, 1 Mar 2025 12:27:30 +0000 (12:27 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 1 Mar 2025 12:27:30 +0000 (12:27 +0000)
app/assets/javascripts/index/directions.js

index c6f83a575e04bc2cc9f0a84a95bdf35666306f81..83995fee3f7a0339302af32cc09295fc158cd305 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 = {};