What's here on a right click / long press / Alt+click (the Design canvas' Desktop): the position on top (a click copies it, with the DMS and the ground's height), Route here / Add to the trip / Save a point, the features' raw properties folded under it; C copies the position under the mouse. Voice prompts while navigating (speechSynthesis, Valhalla's verbal alert and pre-transition instructions, ~25 s and ~7 s ahead), on/off in drive mode's Menu, off by default. TODO: the touch items closed (the Pad7 is fine as it is)
CI / check (push) Successful in 25s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-03 17:44:27 +01:00
1 parent f15fbef746
commit ad975bcf62
8 files changed
+134 -36

No files matched your search

+24
View File
@@ -39,6 +39,12 @@ const TRACE_STEP_M = 10; // fixes kept for /api/road at least this far apart
const LANES_AHEAD_M = 1000; // the next maneuver's lanes from this close
const DEFAULT_WIDGETS = { inclinometer: true, speed: true, altitude: true, navigation: true, banner: true };
const THEN_M = 300; // the maneuver after the next one shown with it when it follows this closely
// Voice prompts (speechSynthesis, Valhalla's verbal instructions), on/off in
// drive mode's Menu: "In 400 m, turn right…" from SOON_S ahead, the
// instruction itself NOW_S before the maneuver (at least the metres given).
export const VOICE_KEY = "maptool.voice";
const SOON_S = 25, SOON_M = 400;
const NOW_S = 7, NOW_M = 60;
const DEFAULT_OPACITY = 0.45; // the card's background, the map shows through
const load = () => {
@@ -187,7 +193,9 @@ export class DashboardControl {
this._lastAt = 0;
this._offFixes = 0;
this._sentKm = undefined; // the new route drawn by the next fix
this._said = new Set();
}));
this._said = new Set(); // voice prompts given: "maneuver index:soon|now"
this._trace = []; // [lon, lat] fixes TRACE_STEP_M apart, for /api/road
this._road = null; // its last answer
this._roadAt = 0;
@@ -228,6 +236,21 @@ export class DashboardControl {
notifyRouteProgress(km);
}
_speak(index, maneuver, m, speed) {
let voiceOn = false;
try { voiceOn = localStorage.getItem(VOICE_KEY) === "on"; } catch { /* private window */ }
if (!voiceOn || !window.speechSynthesis) return;
const now = Math.max(NOW_M, speed * NOW_S);
let stage = null, text = null;
if (m <= now) [stage, text] = ["now", maneuver.say];
else if (m <= Math.max(SOON_M, speed * SOON_S) && m > 2 * now && maneuver.alert) {
[stage, text] = ["soon", `In ${distance(m).replace(" m", " meters").replace(" km", " kilometers")}, ${maneuver.alert[0].toLowerCase()}${maneuver.alert.slice(1)}`];
}
if (!text || this._said.has(`${index}:${stage}`)) return;
this._said.add(`${index}:soon`).add(`${index}:${stage}`);
speechSynthesis.speak(new SpeechSynthesisUtterance(text));
}
// The limit and what's ahead: from the route while on it, else the road.
_navigate() {
const { lat, lon, speed } = this._values;
@@ -261,6 +284,7 @@ export class DashboardControl {
then: maneuver && then && then.at - maneuver.at <= THEN_M / 1000 ? then : null,
street: onStreet,
};
if (maneuver && off <= ON_ROUTE_M) this._speak(index, maneuver, (maneuver.at - at) * 1000, speed ?? 0);
return;
}
this._progress(null);