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
+22
-3
@@ -1,6 +1,6 @@
|
||||
import { Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs";
|
||||
import { ROUTE_ICON, POSITION_ICON, SAVED_POINT_ICON, REVERSE_ICON, CLEAR_ICON, SAVE_ICON } from "/js/icons.js";
|
||||
import { notifySidePanelOpen, onlyOneSidePanelOpen, notifyGpxStoreChanged, onRoutePoint, onRouteEdit, notifyRouteChanged, onReroute } from "/js/panels.js";
|
||||
import { notifySidePanelOpen, onlyOneSidePanelOpen, notifyGpxStoreChanged, onRoutePoint, onRouteEdit, notifyRouteChanged, onReroute, onRouteProgress } from "/js/panels.js";
|
||||
import { isLoggedIn } from "/js/auth.js";
|
||||
import { wirePreview } from "/js/preview.js";
|
||||
import { elevationAt } from "/js/dem.js";
|
||||
@@ -52,12 +52,14 @@ export class RoutePanelControl {
|
||||
// Rerouting (the dashboard, off the route): the start and the via points
|
||||
// already passed give way to the current position.
|
||||
onReroute(({ from, passed }) => {
|
||||
if (this._points.length < 2) return;
|
||||
// the shared trip is rerouted by the server, off its own GNSS (TripStore#follow)
|
||||
if (this._shared || this._points.length < 2) return;
|
||||
this._points.splice(0, 1 + passed).forEach((p) => p.marker.remove());
|
||||
this._addPoint(from, "My position", { quiet: true });
|
||||
this._points.unshift(this._points.pop());
|
||||
this._changed();
|
||||
});
|
||||
onRouteProgress((km) => this._showProgress(km));
|
||||
onRoutePoint(({ lngLat, name }) => {
|
||||
this._setOpen(true);
|
||||
this._addPoint(lngLat, name);
|
||||
@@ -455,7 +457,7 @@ export class RoutePanelControl {
|
||||
source.setData(data);
|
||||
return;
|
||||
}
|
||||
this._map.addSource(SOURCE, { type: "geojson", data });
|
||||
this._map.addSource(SOURCE, { type: "geojson", data, lineMetrics: true }); // line-progress for _showProgress
|
||||
this._map.addLayer({
|
||||
id: `${SOURCE}-casing`,
|
||||
type: "line",
|
||||
@@ -480,6 +482,23 @@ export class RoutePanelControl {
|
||||
});
|
||||
}
|
||||
|
||||
// Navigated (km along the route, docs/design.adoc): the driven part
|
||||
// dimmed, the rest magenta (--route-active); null: the planned blue.
|
||||
_showProgress(km) {
|
||||
if (!this._map.getLayer(`${SOURCE}-line`)) return;
|
||||
const total = this._route?.properties.distance_km;
|
||||
if (km == null || !total) {
|
||||
this._map.setPaintProperty(`${SOURCE}-line`, "line-gradient", undefined);
|
||||
return;
|
||||
}
|
||||
const css = getComputedStyle(document.documentElement);
|
||||
const active = css.getPropertyValue("--route-active").trim() || "#a21caf";
|
||||
const driven = css.getPropertyValue("--ui-muted").trim() || "#6b6b66";
|
||||
const fraction = Math.min(1, Math.max(0, km / total));
|
||||
this._map.setPaintProperty(`${SOURCE}-line`, "line-gradient",
|
||||
fraction > 0 ? ["step", ["line-progress"], driven, fraction, active] : ["step", ["line-progress"], active, 1, active]);
|
||||
}
|
||||
|
||||
// A route item in the library ("Routes" folder), keeping its points and
|
||||
// vehicle so it can be routed again later; an edited one is updated in
|
||||
// place.
|
||||
|
||||
Reference in new issue
Block a user