Driving bar after the research: four 76 px buttons (zoom ±, 2D/3D, route overview), one Follow button bottom left shown only while the map isn't following, night and exit off the bar; research on day/night and on driving buttons (Garmin aviation/marine/zūmo, ships' ECDIS/S-Mode, Android Auto) in docs/design.adoc, its follow-ups in TODO
CI / check (push) Successful in 21s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-01 02:02:55 +01:00
1 parent 9b797fd48c
commit 0eb9d05cdc
5 files changed
+211 -36

No files matched your search

+11
View File
@@ -94,6 +94,10 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod
* [x] Side panels as an overlay in portrait instead of a pinned column — under 640 px the pin is ignored and the panel floats over the map at full width (a pinned 300 px panel left the phone a sliver of map); a real bottom sheet still open * [x] Side panels as an overlay in portrait instead of a pinned column — under 640 px the pin is ignored and the panel floats over the map at full width (a pinned 300 px panel left the phone a sliver of map); a real bottom sheet still open
* [x] Driving mode (field test in the car, 2026-11): tiny icons and lists can't be hit while driving — a separate big-button UI for the few things needed on the road (navigate/follow, night mode, zoom, layer presets) rather than enlarging every planning panel. Done: "Drive" in the topbar (`driving.js`), per device — Follow, zoom, 2D/3D, night, route overview, exit down the left side; the sidebar and panels hidden * [x] Driving mode (field test in the car, 2026-11): tiny icons and lists can't be hit while driving — a separate big-button UI for the few things needed on the road (navigate/follow, night mode, zoom, layer presets) rather than enlarging every planning panel. Done: "Drive" in the topbar (`driving.js`), per device — Follow, zoom, 2D/3D, night, route overview, exit down the left side; the sidebar and panels hidden
** [ ] Layer presets on the driving bar ** [ ] Layer presets on the driving bar
** [x] The bar after the research (docs/design.adoc, "Buttons while driving"): four buttons
(zoom ±, view, overview), Follow and "Back to the position" one button shown only when not
following, 76×76 px; night and exit off the bar
** [ ] Softkeys: the CAN keypad's labels on the screen edge next to its keys (G1000 style)
* [x] Night mode — topbar button cycles auto (sun below the horizon at the map center) / on / off. The map has its own night palette (`NightMap` in `public/js/map_themes.js`, switched live with setPaintProperty): dark blue-gray ground, roads a step lighter, muted ochre motorways, light-gray labels on dark halos; raster overlays dimmed, our own track/point colors kept * [x] Night mode — topbar button cycles auto (sun below the horizon at the map center) / on / off. The map has its own night palette (`NightMap` in `public/js/map_themes.js`, switched live with setPaintProperty): dark blue-gray ground, roads a step lighter, muted ochre motorways, light-gray labels on dark halos; raster overlays dimmed, our own track/point colors kept
** [x] The rest of the UI is still one invert+dim filter — CSS color tokens and a real dark set instead ** [x] The rest of the UI is still one invert+dim filter — CSS color tokens and a real dark set instead
* [x] Tracker as a top-down vehicle (car / motorbike / bicycle from its icon) rotated by the GNSS course, kept while standing still; "Navigate" (tracker card or Overlays status) follows it heading-up, tilted 60°, vehicle in the lower third — panning by hand ends it * [x] Tracker as a top-down vehicle (car / motorbike / bicycle from its icon) rotated by the GNSS course, kept while standing still; "Navigate" (tracker card or Overlays status) follows it heading-up, tilted 60°, vehicle in the lower third — panning by hand ends it
@@ -314,6 +318,13 @@ Planning in the NPS look, driving in the cockpit look, joined by the Unigrid bla
the dark map; night mode sets Night, "◑" Dusk (the day map) the dark map; night mode sets Night, "◑" Dusk (the day map)
. [ ] A Dusk map (between Park Tiles and `NightMap`), the map's palette following the UI's . [ ] A Dusk map (between Park Tiles and `NightMap`), the map's palette following the UI's
. [ ] Daylight: a full-opacity bezel preset for sun on the screen . [ ] Daylight: a full-opacity bezel preset for sun on the screen
. [ ] The display's backlight apart from the palette (as G1000/GPSMAP): the car's screen dimmed
for Night (DDC/CI or its own dimmer), the palette only picks the colors
. [ ] Auto night by the headlights (car CAN) or a light sensor on a node, with hysteresis
(not flipping in a tunnel) — the sun only as the fallback
. [ ] A red/black night palette (Garmin marine / Raymarine) for the darkest roads
. [ ] One night mode for every screen in the car (the server's, like Garmin over NMEA 2000)
. [ ] No flash back to Day at night: the palette switch eased in
=== HW integration === HW integration
+129
View File
@@ -100,6 +100,135 @@ The driving mode (`driving.js`, "Drive" in the topbar) is the cockpit's
input side: big band-black buttons down the map's left — follow, zoom, input side: big band-black buttons down the map's left — follow, zoom,
2D/3D, night, the route overview — and the planning sidebar hidden. 2D/3D, night, the route overview — and the planning sidebar hidden.
=== How others switch day and night (research, 2026-12-01)
[cols="1,3"]
|===
|Who |How
|Garmin G1000 / G3X (aviation)
|Color scheme *Day / Night / Auto* apart from the *backlight*, which a
photocell sets on its own (a curve between a minimum and maximum, and a
time constant so it doesn't jump), or the aircraft's dimmer bus, or by
hand (down to 0.22 % on the PFD).
|Garmin GPSMAP (boats)
|Color mode Day / Night / Auto (by the time of day or the light outside);
the night scheme itself selectable: *full color, red and black, or green
and black*; the backlight a setting of its own; display settings shared
with the other displays over NMEA 2000. Night charts "in muted tones
with enhanced contrast".
|Raymarine (boats)
|Night mode: red text and icons on dark backgrounds; warns that going
back to Day at night jumps to full brightness and spoils night vision.
|Garmin zūmo (motorbikes)
|Day / Night / Auto (by the time of day), brightness by hand — no
light sensor found in the manuals.
|Ships (IMO MSC.191(79), IEC 62288, S-52)
|Colors and brightness for daylight, dusk and night, readable everywhere
on the bridge "with due consideration to the night vision" of the watch;
color never alone (size, shape, orientation too), red for alarms.
Furuno: Day / Dusk / Night palettes, each in a gray or blue variant, at
about 110 / 50 / 5 cd/m²; JRC: Day Bright, Day Whiteback, Day Blackback,
Dusk, Night.
|Android Auto / CarPlay (cars)
|Automatic by the car's headlights or its light sensor, Day / Night by
hand; known to flip in tunnels and under bridges.
|===
What it means for us:
* *Colors and brightness are two controls.* Everyone keeps the palette
(which colors) apart from the backlight (how bright); Night at ~5 cd/m²
is a backlight thing — CSS can't get a lit display that dim. The car's
display's backlight (DDC/CI or the panel's own dimmer) wanted for that.
* *Auto by what the vehicle knows:* the sun today; the headlights from
the car's CAN once they're on the bus (as Android Auto), a light sensor
on a node later (as the photocell) — with hysteresis, not flipping in a
tunnel.
* *A red night* (red/black) as Garmin's and Raymarine's option, for the
darkest roads.
* *One setting for all the car's screens* (Garmin shares it over NMEA
2000): the night mode the server's, not each browser's, when they're in
the same car.
* *No flash on the way back to Day* at night: the switch eased in.
Sources: Garmin G1000 manual (Display backlighting); Garmin G3X install
manual (photocell parameters); Garmin GPSMAP display settings and
"Changing the color mode" help pages; Garmin's "Navigate confidently in
the dark" blog; Raymarine display mode docs; Garmin zūmo 395/396 display
settings; IMO MSC.191(79) §5.3, §5.5; Furuno FAR-2107 / FE-800 and JRC
JAN-701B manuals; Google Maps / Waze help and 9to5Google on Android Auto.
=== Buttons while driving: how others do it (research, 2026-12-01)
Our driving bar (`driving.js`) came from OsmAnd's map buttons: seven
76×64 px buttons down the left (follow, zoom ±, 2D/3D, night, route
overview, exit). What the others do:
[cols="1,3"]
|===
|Who |How
|Android Auto (Google's car design guidelines)
|Touch targets at least *76×76 dp* (the distance to the head unit, quick
taps); content readable in *2 s*, a response within 0.25 s; the map's
*action strip at most four buttons* (pan, recenter, zoom in/out). Google
Maps: *recenter only appears once the map was moved* and goes when
tapped; the compass toggles heading-up / north-up; route overview,
sound (mute / alerts only) and report on the edges.
|Garmin zūmo XT (motorbikes)
|The rider *picks which buttons the map shows* (a wrench, top left); the
rest in a side panel from the bottom right; reviewers still find the
buttons small with gloves.
|Garmin G1000 (aviation)
|*Softkeys*: a fixed row of physical keys along the display's bottom
bezel, their labels drawn on the screen right above them, changing with
the page; concentric knobs for values. Nothing to aim at — the hand finds
the key.
|Garmin G3000 (aviation)
|Most input moved off the displays onto separate *touch controllers*
(GTC) on the pedestal, each driving a pane of the big displays; some
knobs and keys kept.
|Ships (ECDIS, IMO S-Mode MSC.1/Circ.1609)
|Trackball and a key panel with *dedicated keys* (dimming up/down among
them); S-Mode standardizes the terms, icons and hot keys of the common
functions so every bridge works the same.
|===
What it means for us:
* *Fewer buttons on the map*: four, not seven — zoom +, zoom −, the
view (2D/3D, heading-up/north-up), the route overview. Night is
automatic (and a topbar thing), "exit" is the topbar's Drive button
already.
* *Recenter only when needed*: "Follow" and "Back to the position" are the
same thing — one button, shown only while the map isn't following, in
one place.
* *76 px square* targets at least (ours are 76×64).
* *Softkeys for the CAN keypad* (Blink Marine style): its keys' labels
on the screen's edge next to them, changing with the screen — the G1000
way, no aiming while driving.
* *A second screen as the controller* (G3000's GTC): the tablet or phone
drives the cab's display (the shared trip already works that way for
the route).
* *Pick your buttons* (zūmo) — later, if four fixed ones don't fit.
Sources: Google's car design guidelines (sizing; map action strip);
Google Maps help and the Navigation SDK docs (recenter, compass,
overview); zūmo XT owner's manual and reviews (Motorcycle.com, Bennetts);
Garmin G1000 pilot's guide (softkeys, knobs); AIN and Aviation Consumer on
the G3000's GTCs; JRC JAN-701B and Kongsberg ECDIS manuals; IMO
MSC.1/Circ.1609.
== Typography == Typography
* Planning UI: the system sans; *National Park* (the router-carved * Planning UI: the system sans; *National Park* (the router-carved
+28 -5
View File
@@ -3544,9 +3544,10 @@ html.driving #map .maplibregl-ctrl-top-left { display: none; }
max-height: calc(100% - 24px); /* a low screen: the buttons shrink, to 44 px */ max-height: calc(100% - 24px); /* a low screen: the buttons shrink, to 44 px */
} }
.drive-bar[hidden] { display: none; } .drive-bar[hidden] { display: none; }
.drive-bar button { .drive-bar button,
.drive-bar__recenter {
width: 76px; width: 76px;
flex: 0 1 64px; flex: 0 1 76px;
min-height: 44px; min-height: 44px;
border: none; border: none;
border-radius: 12px; border-radius: 12px;
@@ -3557,11 +3558,33 @@ html.driving #map .maplibregl-ctrl-top-left { display: none; }
box-shadow: 0 2px 8px rgb(0 0 0 / 0.35); box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
cursor: pointer; cursor: pointer;
} }
.drive-bar .drive-bar__follow,
.drive-bar .drive-bar__overview { font-size: 16px; } .drive-bar .drive-bar__overview { font-size: 16px; }
.drive-bar button:active { background: var(--accent); } .drive-bar button:active,
.drive-bar__recenter:active { background: var(--accent); }
/* the one follow / back-to-the-position button, bottom left, only while
the map isn't following (driving.js); gnss.js's own one not meanwhile */
.drive-bar__recenter {
position: absolute;
left: 12px;
bottom: 36px;
z-index: 4;
width: auto;
height: 76px;
padding: 0 22px;
border: none;
border-radius: 12px;
background: var(--band);
color: var(--band-fg);
font-size: 18px;
font-weight: 700;
box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
cursor: pointer;
}
.drive-bar__recenter[hidden],
html.driving .follow-resume { display: none; }
.drive-bar button:disabled { opacity: 0.4; } .drive-bar button:disabled { opacity: 0.4; }
html.follow-3d .maplibregl-ctrl-overview-map { display: none; } html.follow-3d .maplibregl-ctrl-overview-map { display: none; }
.drive-bar .drive-bar__night { font-size: 30px; }
/* npmap's home button draws its house in #333: the UI's text color instead */ /* npmap's home button draws its house in #333: the UI's text color instead */
.feather-home { fill: var(--ui-fg); } .feather-home { fill: var(--ui-fg); }
:root[data-palette] .drive-bar button,
:root[data-palette] .drive-bar__recenter { box-shadow: 0 0 0 1px var(--ui-line), 0 2px 8px rgb(0 0 0 / 0.35); }
+36 -31
View File
@@ -1,12 +1,16 @@
import { LngLatBounds } from "/vendor/maplibre-gl/maplibre-gl.mjs"; import { LngLatBounds } from "/vendor/maplibre-gl/maplibre-gl.mjs";
import { requestGnssFollow, onRouteChanged } from "/js/panels.js"; import { requestGnssFollow, onRouteChanged } from "/js/panels.js";
import { pauseFollow, resumeFollow } from "/js/gnss.js"; import { pauseFollow, resumeFollow, isFollowing } from "/js/gnss.js";
// Driving mode: the few things needed on the road as big buttons down the // Driving mode: the few things needed on the road as big buttons, the
// side of the map, the planning sidebar and panels out of the way (TODO: // planning sidebar and panels out of the way. After the research in
// tiny icons can't be hit while driving). Per device (localStorage). // docs/design.adoc ("Buttons while driving"): four buttons on the map
// (Android Auto's action strip: at most four, 76 px), the recenter button
// only while the map isn't following (as Google Maps), night automatic and
// leaving by the topbar's Drive. Per device (localStorage).
const KEY = "drivingMode"; const KEY = "drivingMode";
const PITCH_3D = 60; // as map.js's 3D toggle const PITCH_3D = 60; // as map.js's 3D toggle
const CHECK_MS = 1000; // how often the recenter button looks whether the map follows
export function setupDriving(map, nightButton) { export function setupDriving(map, nightButton) {
let route = onRouteChanged((r) => (route = r)); let route = onRouteChanged((r) => (route = r));
@@ -17,47 +21,48 @@ export function setupDriving(map, nightButton) {
toggle.textContent = "Drive"; toggle.textContent = "Drive";
nightButton.before(toggle); nightButton.before(toggle);
const button = (name, label, title, action) => {
const el = document.createElement("button");
el.type = "button";
el.className = `drive-bar__${name}`;
el.textContent = label;
el.title = title;
el.setAttribute("aria-label", title);
el.addEventListener("click", action);
return el;
};
const bar = document.createElement("div"); const bar = document.createElement("div");
bar.className = "drive-bar"; bar.className = "drive-bar";
bar.hidden = true; bar.hidden = true;
const buttons = { bar.append(
follow: ["Follow", "Follow the position, heading up in 3D", () => { button("zoomIn", "+", "Zoom in", () => map.zoomIn()),
requestGnssFollow(); button("zoomOut", "−", "Zoom out", () => map.zoomOut()),
resumeFollow(map); button("pitch", "3D", "2D / 3D", () => map.easeTo({ pitch: map.getPitch() > 0 ? 0 : PITCH_3D, ...(map.getPitch() > 0 && { bearing: 0 }), duration: 300 })),
if (map.getPitch() === 0) map.easeTo({ pitch: PITCH_3D, duration: 300 }); button("overview", "Route", "The whole route (the follow pauses)", () => {
}],
zoomIn: ["+", "Zoom in", () => map.zoomIn()],
zoomOut: ["−", "Zoom out", () => map.zoomOut()],
pitch: ["2D", "2D / 3D", () => map.easeTo({ pitch: map.getPitch() > 0 ? 0 : PITCH_3D, ...(map.getPitch() > 0 && { bearing: 0 }), duration: 300 })],
night: ["", "Night mode", () => nightButton.click()],
overview: ["Route", "The whole route (the follow pauses)", () => {
const coords = route?.geometry?.coordinates; const coords = route?.geometry?.coordinates;
if (!coords?.length) return; if (!coords?.length) return;
pauseFollow(map); pauseFollow(map);
map.fitBounds(coords.reduce((b, c) => b.extend(c), new LngLatBounds(coords[0], coords[0])), { padding: 80, pitch: 0, bearing: 0 }); map.fitBounds(coords.reduce((b, c) => b.extend(c), new LngLatBounds(coords[0], coords[0])), { padding: 80, pitch: 0, bearing: 0 });
}], }),
exit: ["✕", "Leave driving mode", () => set(false)], );
}; // the one "follow / back to the position", bottom left, only when needed
for (const [name, [label, title, action]] of Object.entries(buttons)) { const recenter = button("recenter", "Follow", "Follow the position, heading up in 3D", () => {
const button = document.createElement("button"); requestGnssFollow();
button.type = "button"; resumeFollow(map);
button.className = `drive-bar__${name}`; if (map.getPitch() === 0) map.easeTo({ pitch: PITCH_3D, duration: 300 });
button.textContent = label; recenter.hidden = true;
button.title = title; });
button.setAttribute("aria-label", title); recenter.hidden = true;
button.addEventListener("click", action); map.getContainer().append(bar, recenter);
bar.appendChild(button);
}
map.getContainer().appendChild(bar);
const render = () => { const render = () => {
bar.querySelector(".drive-bar__pitch").textContent = map.getPitch() > 0 ? "2D" : "3D"; bar.querySelector(".drive-bar__pitch").textContent = map.getPitch() > 0 ? "2D" : "3D";
bar.querySelector(".drive-bar__night").textContent = nightButton.textContent;
bar.querySelector(".drive-bar__overview").disabled = !route; bar.querySelector(".drive-bar__overview").disabled = !route;
recenter.hidden = bar.hidden || isFollowing(map);
}; };
map.on("pitchend", render); map.on("pitchend", render);
nightButton.addEventListener("click", render);
onRouteChanged(render); onRouteChanged(render);
setInterval(render, CHECK_MS);
function set(on) { function set(on) {
document.documentElement.classList.toggle("driving", on); document.documentElement.classList.toggle("driving", on);
+7
View File
@@ -57,6 +57,13 @@ export function pauseFollow(map) {
state.timer = setTimeout(() => (state.button.hidden = true), FREE_LOOK_MS); state.timer = setTimeout(() => (state.button.hidden = true), FREE_LOOK_MS);
} }
// Is the map following a position right now (a follow step lately, not
// paused by hand)? For the driving bar's recenter button.
export function isFollowing(map) {
const state = freeLookState(map);
return Date.now() - state.followedAt <= FOLLOWING_MS && Date.now() >= state.until;
}
export function resumeFollow(map) { export function resumeFollow(map) {
const state = freeLookState(map); const state = freeLookState(map);
state.until = 0; state.until = 0;