X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/648b8ba1f83e9923bb43a9175ea548405c9a403d..a1761602870b76d79662f2cec8b7b80d8dd5baa4:/app/assets/javascripts/index/directions.js diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index ee8d3b8c5..40ca85d96 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -248,7 +248,7 @@ OSM.Directions = function (map) { }); select.on("change", function (e) { - setEngine(e.target.selectedOptions[0].value + "_" + chosenEngine.mode); + setEngine(e.target.value + "_" + chosenEngine.mode); Cookies.set("_osm_directions_engine", chosenEngine.id, { secure: true, expires: expiry, path: "/", samesite: "lax" }); getRoute(true, true); }); @@ -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 = {}; @@ -344,7 +346,7 @@ OSM.Directions = function (map) { OSM.Directions.engines = []; OSM.Directions.addEngine = function (engine, supportsHTTPS) { - if (document.location.protocol === "http:" || supportsHTTPS) { + if (location.protocol === "http:" || supportsHTTPS) { engine.id = engine.provider + "_" + engine.mode; OSM.Directions.engines.push(engine); }