});
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);
});
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 = {};
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);
}