Navigation: arrived 30 m from the end (banner, drive mode), navigating on past it (the reroute turns back); the next maneuver's lanes from 1 km or 45 s at the speed driven, in drive mode a cell under the maneuver over the map ("ahead" in the profile, shown only with something in it) with the next traffic signal; signals with no route: /api/road also routes 1.5 km straight on from the last fix and gives that way's signals, the nearest one in front shown. TODO: the CAN GNSS follow done (the LTE tracker a layer to switch on), any tracker point followable later
CI / check (push) Successful in 1m22s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-03 17:57:27 +01:00
1 parent ad975bcf62
commit a6158f4083
7 files changed
+110 -15

No files matched your search

+16 -1
View File
@@ -3,7 +3,7 @@ import { requestGnssFollow, onRouteChanged } from "/js/panels.js";
import { pauseFollow, resumeFollow, isFollowing } from "/js/gnss.js";
import { formatDuration } from "/js/route.js";
import { isLoggedIn } from "/js/auth.js";
import { watchDashboard, maneuverSvg, distance, VOICE_KEY } from "/js/dashboard.js";
import { watchDashboard, maneuverSvg, laneSvg, distance, VOICE_KEY } from "/js/dashboard.js";
import { formatSunInfo } from "/js/sun.js";
import { pointsMenu, layersMenu, terrainMenu, elevationHtml, cellButton, bindKey, emptyRow as empty, escapeHtml } from "/js/drive_menus.js";
@@ -467,10 +467,24 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
}
};
// Under the maneuver, over the map, only when there's something: the next
// maneuver's lanes (from 1 km, further at speed) and the next traffic signal.
const renderAhead = (el) => {
const n = dash?.nav;
const lanes = !n?.arrived && n?.maneuver?.lanes && n.maneuver.m <= n.lanesM ? n.maneuver.lanes : null;
const signal = n?.signal != null && n.signal <= 1000 ? n.signal : null;
el.hidden = !lanes && signal == null;
if (el.hidden) return;
el.innerHTML = (lanes ? `<div class="dash-lanes drive-ahead__lanes">${lanes.map(laneSvg).join("")}</div>` : "") +
(signal != null ? `<span class="drive-ahead__signal"><span class="dash-signal"></span>${distance(signal)}</span>` : "");
};
const renderManeuver = (el) => {
const n = dash?.nav;
if (n?.offRoute) {
el.innerHTML = `<div><span class="drive-cell__value drive-cell--caution">Off the route</span><span class="drive-cell__label">rerouting</span></div>`;
} else if (n?.arrived) {
el.innerHTML = `${maneuverSvg(4)}<div class="drive-cell__text"><span class="drive-cell__value">Arrived</span><span class="drive-cell__street">${escapeHtml(n.street || "")}</span></div>`;
} else if (n?.maneuver) {
const { m, type, street, text, exit } = n.maneuver;
const what = street ? `${exit ? `${exit}. exit · ` : ""}${escapeHtml(street)}` : escapeHtml(text);
@@ -515,6 +529,7 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
const [value, unit, cls = "", extra = ""] = fieldValue(name, a);
el.innerHTML = `${extra}<span class="drive-cell__label">${FIELDS[name] || name}</span><span class="drive-cell__value ${cls}">${escapeHtml(value)} <small>${escapeHtml(unit)}</small></span>`;
} else if (cell.widget === "maneuver") renderManeuver(el);
else if (cell.widget === "ahead") renderAhead(el);
else if (cell.widget === "status") {
el.innerHTML = `<b class="drive-status__brand">MAPTOOL</b><span class="drive-cell__muted"><span class="${navigator.onLine ? "drive-status--ok" : ""}">●</span> ${navigator.onLine ? "online" : "offline"}${log?.active ? ` · <span class="drive-status--rec">● rec</span>` : ""}</span>`;
} else if (cell.widget === "elevation") renderElevation(el, cell);