X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/4e9483e5eb8af1ee125b3ada96c5fa716176c490..248b5fa1aefb8c7b4ece818ad3720992f2487fe2:/app/assets/javascripts/index/directions.js diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 97fa961d6..40ca85d96 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 = {};