From: Tom Hughes Date: Sat, 1 Mar 2025 12:27:30 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/5737' X-Git-Tag: live~206 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/ddd7b8e58287adb1b69f32b6de98eb28b09e79d2?hp=8665059a0cabe9395189f3a38df054320dfddd00 Merge remote-tracking branch 'upstream/pull/5737' --- diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index c6f83a575..83995fee3 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -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 = {};