Driving mode ("Drive": big buttons — follow, zoom, 2D/3D, night, route overview — the sidebar hidden); palettes instead of the inversion (the UI's greys onto --ui-*, MapLibre's controls too, night → Night, new ◑ Dusk); the navigated route magenta, the driven part dimmed; route progress only forward (locate near the last position first); rerouting on the server off its own GNSS (TripStore#follow), the browser's only without the shared trip; the overview map hidden while following in 3D; the topbar's items apart
This commit is contained in:
1 parent
12b4ac6725
commit
07a4d363ec
13 files changed
+520
-219
No files matched your search
+17
-4
@@ -29,6 +29,7 @@ import { offerSharedFiles } from "/js/share_import.js";
|
||||
import HomeButton from "/vendor/npmap-home-button/home-button.esm.js";
|
||||
import OverviewMap from "/vendor/npmap-overview/overview.esm.js";
|
||||
import * as maplibregl from "/vendor/maplibre-gl/maplibre-gl.mjs";
|
||||
import { setupDriving } from "/js/driving.js";
|
||||
|
||||
const CENTER = [17.1077, 48.1486];
|
||||
const ZOOM = 13;
|
||||
@@ -467,10 +468,18 @@ updateSun();
|
||||
map.on("moveend", updateSun);
|
||||
setInterval(updateSun, 60000);
|
||||
|
||||
// Night mode (html.night, style.css) so the screen doesn't glare in the
|
||||
// car: "auto" follows the sun at the map center, or forced on/off — the
|
||||
// topbar button cycles the three, remembered per device.
|
||||
const NIGHT_MODES = { auto: ["◐", "Night mode: automatic (after sunset)"], on: ["☾", "Night mode: on"], off: ["☀", "Night mode: off"] };
|
||||
// Night mode so the screen doesn't glare in the car: "auto" follows the sun
|
||||
// at the map center, or by hand — the topbar button cycles them,
|
||||
// remembered per device.
|
||||
// The UI's palette (style.css, after S-52: Day, Dusk, Night) and the map's
|
||||
// night style: automatic by the sun, or by hand — Dusk the dark UI over the
|
||||
// day map, "for optional use by day as well" (docs/design.adoc).
|
||||
const NIGHT_MODES = {
|
||||
auto: ["◐", "Night mode: automatic (after sunset)"],
|
||||
on: ["☾", "Night mode: on"],
|
||||
dusk: ["◑", "Dusk: the dark UI over the day map"],
|
||||
off: ["☀", "Night mode: off"],
|
||||
};
|
||||
const nightButton = document.querySelector(".topbar__night");
|
||||
const nightMap = new NightMap(map);
|
||||
// The base style's texture patterns (grass, scrub, military hatch) and the
|
||||
@@ -506,6 +515,9 @@ const updateNight = () => {
|
||||
const { lng, lat } = sunAt;
|
||||
const dark = nightMode === "on" || (nightMode === "auto" && getPosition(new Date(), lat, lng).altitude < 0);
|
||||
document.documentElement.classList.toggle("night", dark);
|
||||
const palette = dark ? "night" : nightMode === "dusk" ? "dusk" : null;
|
||||
if (palette) document.documentElement.dataset.palette = palette;
|
||||
else delete document.documentElement.dataset.palette;
|
||||
nightMap.set(dark);
|
||||
[nightButton.textContent, nightButton.title] = NIGHT_MODES[nightMode] || NIGHT_MODES.auto;
|
||||
};
|
||||
@@ -520,6 +532,7 @@ nightButton.addEventListener("click", () => {
|
||||
updateNight();
|
||||
map.on("moveend", updateNight);
|
||||
setInterval(updateNight, 60000);
|
||||
setupDriving(map, nightButton);
|
||||
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
|
||||
|
||||
Reference in new issue
Block a user