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)
This commit is contained in:
1 parent
f15fbef746
commit
ad975bcf62
8 files changed
+134
-36
No files matched your search
@@ -89,12 +89,12 @@ independence from connectivity.
|
|||||||
The app is already reachable from the internet behind login, so a tablet is enough to
|
The app is already reachable from the internet behind login, so a tablet is enough to
|
||||||
plan from — the server does the heavy lifting. The UI is built for a mouse today.
|
plan from — the server does the heavy lifting. The UI is built for a mouse today.
|
||||||
|
|
||||||
* [ ] Touch targets ≥ 44 px (tree rows, panel buttons, icon grids)
|
* [x] Touch targets ≥ 44 px (tree rows, panel buttons, icon grids) — on the Pad7 everything is big enough (2026-12-03), nothing more to do
|
||||||
** [x] Route markers: an invisible 48px grab area around the dot (a finger missed the 26px dot and panned the map)
|
** [x] Route markers: an invisible 48px grab area around the dot (a finger missed the 26px dot and panned the map)
|
||||||
** [x] Tracks & Points open/close arrows: a 24×28 px hit area, 36×40 on touch screens
|
** [x] Tracks & Points open/close arrows: a 24×28 px hit area, 36×40 on touch screens
|
||||||
** [x] Notes can be moved (Move in the popup: drag the marker or tap the new spot), and new/edited points get an icon, a color and B/I buttons
|
** [x] Notes can be moved (Move in the popup: drag the marker or tap the new spot), and new/edited points get an icon, a color and B/I buttons
|
||||||
* [ ] Nothing reachable only by hover — tooltips and flyouts must open on tap too
|
* [x] Nothing reachable only by hover — tooltips and flyouts must open on tap too
|
||||||
* [ ] A touch substitute for the Alt+click debug inspector (e.g. long-press)
|
* [x] A touch substitute for the Alt+click debug inspector (e.g. long-press) — the long press is a contextmenu: what's here
|
||||||
* [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
|
||||||
** [x] Layer presets on the driving bar (Layers: Road / Off-road / Overnight, + Keep)
|
** [x] Layer presets on the driving bar (Layers: Road / Off-road / Overnight, + Keep)
|
||||||
@@ -163,9 +163,11 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod
|
|||||||
text fields. Who: the navigator (co-driver) runs the whole UI and the trip's points on the
|
text fields. Who: the navigator (co-driver) runs the whole UI and the trip's points on the
|
||||||
16" display; the driver only looks at a finished map on Android Auto, touching the 16"
|
16" display; the driver only looks at a finished map on Android Auto, touching the 16"
|
||||||
only now and then — so it's simple for a moving car, not driver-distraction rules
|
only now and then — so it's simple for a moving car, not driver-distraction rules
|
||||||
* [ ] Desktop (the Design canvas' Desktop, 2026-12-03): copy the position under the cursor
|
* [x] Desktop (the Design canvas' Desktop, 2026-12-03): copy the position under the cursor
|
||||||
to the clipboard (a key or the right-click menu) — today only the map's center copies,
|
to the clipboard (a key or the right-click menu) — today only the map's center copies,
|
||||||
from the status bar, so the way around it is to put the center on the point first
|
from the status bar, so the way around it is to put the center on the point first. Done: right
|
||||||
|
click / long press / Alt+click = what's here (the position, a click copies it; Route here, Add to
|
||||||
|
the trip, Save a point; the features' raw properties folded), C copies the position under the mouse
|
||||||
* [x] Desktop: the scale back over the map, not in the status bar
|
* [x] Desktop: the scale back over the map, not in the status bar
|
||||||
* [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
|
||||||
@@ -329,8 +331,10 @@ already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/espho
|
|||||||
gain `type`, `street`, `exit`
|
gain `type`, `street`, `exit`
|
||||||
** [x] The driving view decluttered: tilted to 3D (≥ 30°), route numbers and minor roads' /
|
** [x] The driving view decluttered: tilted to 3D (≥ 30°), route numbers and minor roads' /
|
||||||
paths' names hidden; road labels 1.5× further apart, past z15 the same ground distance
|
paths' names hidden; road labels 1.5× further apart, past z15 the same ground distance
|
||||||
** [ ] Turn-by-turn voice (`speechSynthesis`), the route ahead highlighted / the driven part
|
** [x] Turn-by-turn voice (`speechSynthesis`), the route ahead highlighted / the driven part
|
||||||
greyed
|
greyed. Voice: Valhalla's `verbal_transition_alert_instruction` ("In 400 meters, …", 25 s / ≥ 400 m
|
||||||
|
ahead) and `verbal_pre_transition_instruction` (7 s / ≥ 60 m ahead), English; on/off in drive
|
||||||
|
mode's Menu, off by default
|
||||||
** [x] Lanes as SVG arrows, one per direction bit, the lanes to take (Valhalla's `active`) blue
|
** [x] Lanes as SVG arrows, one per direction bit, the lanes to take (Valhalla's `active`) blue
|
||||||
with that direction bold
|
with that direction bold
|
||||||
*** [ ] Lane guidance before motorway exits (lanes several maneuvers ahead), bigger on the
|
*** [ ] Lane guidance before motorway exits (lanes several maneuvers ahead), bigger on the
|
||||||
@@ -379,8 +383,8 @@ already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/espho
|
|||||||
*** [ ] Replay a library track (GPX/FIT with times) instead, at its own speed
|
*** [ ] Replay a library track (GPX/FIT with times) instead, at its own speed
|
||||||
** [x] Free look while following: moving the map by hand pauses the follow, "Back to the
|
** [x] Free look while following: moving the map by hand pauses the follow, "Back to the
|
||||||
position" or 15 s untouched resumes it
|
position" or 15 s untouched resumes it
|
||||||
* [ ] While following a planned route: the route ahead highlighted, distance to the next
|
* [x] While following a planned route: the route ahead highlighted, distance to the next
|
||||||
maneuver from Valhalla's directions
|
maneuver from Valhalla's directions (the banner; the driven part dashed)
|
||||||
|
|
||||||
=== Design: the park brochure and the cockpit
|
=== Design: the park brochure and the cockpit
|
||||||
|
|
||||||
|
|||||||
@@ -265,7 +265,8 @@ module Maptool
|
|||||||
|
|
||||||
def self.maneuver(m)
|
def self.maneuver(m)
|
||||||
{ text: m["instruction"], km: m["length"], type: m["type"], street: (m["begin_street_names"] || m["street_names"])&.first,
|
{ text: m["instruction"], km: m["length"], type: m["type"], street: (m["begin_street_names"] || m["street_names"])&.first,
|
||||||
exit: m["roundabout_exit_count"], lanes: m["lanes"] }.compact
|
exit: m["roundabout_exit_count"], lanes: m["lanes"],
|
||||||
|
alert: m["verbal_transition_alert_instruction"], say: m["verbal_pre_transition_instruction"] }.compact
|
||||||
end
|
end
|
||||||
private_class_method :maneuver
|
private_class_method :maneuver
|
||||||
|
|
||||||
|
|||||||
@@ -1504,6 +1504,21 @@ button.basemap-panel__link[hidden] { display: none; }
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* what's here (map.js): the position, what to do with it, the features folded */
|
||||||
|
.here-popup .maplibregl-popup-content { padding: 0; max-height: 420px; }
|
||||||
|
.here button { font: inherit; color: inherit; cursor: pointer; }
|
||||||
|
.here__position { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 28px 10px 12px; border: none; border-bottom: 1px solid var(--ui-line); background: none; text-align: left; }
|
||||||
|
.here__position > span { flex: 1; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
|
||||||
|
.here__position b { font-size: 15px; }
|
||||||
|
.here__position small, .here__position em { color: var(--ui-muted); font-style: normal; font-size: 12px; }
|
||||||
|
.here__actions { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--ui-line); }
|
||||||
|
.here__actions button { flex: 1; height: 30px; padding: 0 6px; border: 1px solid var(--ui-line); border-radius: 6px; background: none; font-weight: 600; font-size: 12px; white-space: nowrap; }
|
||||||
|
.here__actions button:hover { background: var(--ui-hover, rgba(0, 0, 0, 0.06)); }
|
||||||
|
.here__features { padding: 8px 12px 0; }
|
||||||
|
.here__features summary { font-weight: 600; cursor: pointer; }
|
||||||
|
.here__features .debug-popup__feature:first-of-type { margin-top: 6px; }
|
||||||
|
.here__hint { padding: 6px 12px 8px; font-size: 11px; color: var(--ui-muted); }
|
||||||
|
|
||||||
.maplibregl-ctrl-overview-map {
|
.maplibregl-ctrl-overview-map {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -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 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 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
|
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 DEFAULT_OPACITY = 0.45; // the card's background, the map shows through
|
||||||
|
|
||||||
const load = () => {
|
const load = () => {
|
||||||
@@ -187,7 +193,9 @@ export class DashboardControl {
|
|||||||
this._lastAt = 0;
|
this._lastAt = 0;
|
||||||
this._offFixes = 0;
|
this._offFixes = 0;
|
||||||
this._sentKm = undefined; // the new route drawn by the next fix
|
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._trace = []; // [lon, lat] fixes TRACE_STEP_M apart, for /api/road
|
||||||
this._road = null; // its last answer
|
this._road = null; // its last answer
|
||||||
this._roadAt = 0;
|
this._roadAt = 0;
|
||||||
@@ -228,6 +236,21 @@ export class DashboardControl {
|
|||||||
notifyRouteProgress(km);
|
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.
|
// The limit and what's ahead: from the route while on it, else the road.
|
||||||
_navigate() {
|
_navigate() {
|
||||||
const { lat, lon, speed } = this._values;
|
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,
|
then: maneuver && then && then.at - maneuver.at <= THEN_M / 1000 ? then : null,
|
||||||
street: onStreet,
|
street: onStreet,
|
||||||
};
|
};
|
||||||
|
if (maneuver && off <= ON_ROUTE_M) this._speak(index, maneuver, (maneuver.at - at) * 1000, speed ?? 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._progress(null);
|
this._progress(null);
|
||||||
|
|||||||
+11
-1
@@ -3,7 +3,7 @@ import { requestGnssFollow, onRouteChanged } from "/js/panels.js";
|
|||||||
import { pauseFollow, resumeFollow, isFollowing } from "/js/gnss.js";
|
import { pauseFollow, resumeFollow, isFollowing } from "/js/gnss.js";
|
||||||
import { formatDuration } from "/js/route.js";
|
import { formatDuration } from "/js/route.js";
|
||||||
import { isLoggedIn } from "/js/auth.js";
|
import { isLoggedIn } from "/js/auth.js";
|
||||||
import { watchDashboard, maneuverSvg, distance } from "/js/dashboard.js";
|
import { watchDashboard, maneuverSvg, distance, VOICE_KEY } from "/js/dashboard.js";
|
||||||
import { formatSunInfo } from "/js/sun.js";
|
import { formatSunInfo } from "/js/sun.js";
|
||||||
import { pointsMenu, layersMenu, terrainMenu, elevationHtml, cellButton, bindKey, emptyRow as empty, escapeHtml } from "/js/drive_menus.js";
|
import { pointsMenu, layersMenu, terrainMenu, elevationHtml, cellButton, bindKey, emptyRow as empty, escapeHtml } from "/js/drive_menus.js";
|
||||||
|
|
||||||
@@ -104,6 +104,7 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
|
|||||||
<button type="button" class="drive-panel__close" aria-label="Close">✕</button>
|
<button type="button" class="drive-panel__close" aria-label="Close">✕</button>
|
||||||
<button type="button" class="drive-menu__row" data-action="overview">The whole route <small>the follow pauses</small></button>
|
<button type="button" class="drive-menu__row" data-action="overview">The whole route <small>the follow pauses</small></button>
|
||||||
<button type="button" class="drive-menu__row" data-action="terrain-auto"></button>
|
<button type="button" class="drive-menu__row" data-action="terrain-auto"></button>
|
||||||
|
<button type="button" class="drive-menu__row" data-action="voice"></button>
|
||||||
<button type="button" class="drive-menu__row" data-action="leave">Leave driving mode</button>`;
|
<button type="button" class="drive-menu__row" data-action="leave">Leave driving mode</button>`;
|
||||||
// auto: opens off-road and closes back on the road; stay: opens and stays (the inclinometer all along); hand: neither
|
// auto: opens off-road and closes back on the road; stay: opens and stays (the inclinometer all along); hand: neither
|
||||||
const TERRAIN_MODES = { auto: "opens and closes by itself", stay: "opens by itself, stays", hand: "by hand" };
|
const TERRAIN_MODES = { auto: "opens and closes by itself", stay: "opens by itself, stays", hand: "by hand" };
|
||||||
@@ -117,6 +118,15 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
|
|||||||
renderAuto();
|
renderAuto();
|
||||||
});
|
});
|
||||||
renderAuto();
|
renderAuto();
|
||||||
|
const voiceButton = menuPanel.querySelector('[data-action="voice"]');
|
||||||
|
const voiceOn = () => { try { return localStorage.getItem(VOICE_KEY) === "on"; } catch { return false; } };
|
||||||
|
const renderVoice = () => { voiceButton.innerHTML = `Voice prompts: ${voiceOn() ? "on" : "off"} <small>tap to switch</small>`; };
|
||||||
|
voiceButton.addEventListener("click", () => {
|
||||||
|
try { localStorage.setItem(VOICE_KEY, voiceOn() ? "off" : "on"); } catch { /* private window: not kept */ }
|
||||||
|
if (voiceOn()) window.speechSynthesis?.speak(new SpeechSynthesisUtterance("Voice prompts on"));
|
||||||
|
renderVoice();
|
||||||
|
});
|
||||||
|
renderVoice();
|
||||||
menuPanel.querySelector('[data-action="overview"]').addEventListener("click", overview);
|
menuPanel.querySelector('[data-action="overview"]').addEventListener("click", overview);
|
||||||
menuPanel.querySelector('[data-action="leave"]').addEventListener("click", () => set(false));
|
menuPanel.querySelector('[data-action="leave"]').addEventListener("click", () => set(false));
|
||||||
const crosshair = document.createElement("div");
|
const crosshair = document.createElement("div");
|
||||||
|
|||||||
+59
-23
@@ -20,7 +20,7 @@ import { RoutePanelControl } from "/js/route.js";
|
|||||||
import { WAYPOINT_ICON, SUNRISE_ICON, SUNSET_ICON, PENDING_ICON, LOCK_ICON, UNLOCK_ICON } from "/js/icons.js";
|
import { WAYPOINT_ICON, SUNRISE_ICON, SUNSET_ICON, PENDING_ICON, LOCK_ICON, UNLOCK_ICON } from "/js/icons.js";
|
||||||
import { formatCoords, formatSunInfo, sunChartHtml } from "/js/sun.js";
|
import { formatCoords, formatSunInfo, sunChartHtml } from "/js/sun.js";
|
||||||
import { getPosition } from "/vendor/suncalc/suncalc.js";
|
import { getPosition } from "/vendor/suncalc/suncalc.js";
|
||||||
import { setupSidePanelModes } from "/js/panels.js";
|
import { addRoutePoint, setupSidePanelModes } from "/js/panels.js";
|
||||||
import { isLoggedIn } from "/js/auth.js";
|
import { isLoggedIn } from "/js/auth.js";
|
||||||
import { DebugControl } from "/js/debug.js";
|
import { DebugControl } from "/js/debug.js";
|
||||||
import { setupUpdate } from "/js/update.js";
|
import { setupUpdate } from "/js/update.js";
|
||||||
@@ -285,7 +285,8 @@ map.addControl(new MeasureControl(), "top-right");
|
|||||||
// button that can only ever end in a 401 for a logged-out viewer, same
|
// button that can only ever end in a 401 for a logged-out viewer, same
|
||||||
// "hide the write-only affordance" story as GpxPanelControl's own
|
// "hide the write-only affordance" story as GpxPanelControl's own
|
||||||
// upload/new-folder buttons.
|
// upload/new-folder buttons.
|
||||||
if (isLoggedIn()) map.addControl(new NotesControl(), "top-right");
|
let notesControl = null; // what's here's "Save a point" (below)
|
||||||
|
if (isLoggedIn()) map.addControl((notesControl = new NotesControl()), "top-right");
|
||||||
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-right");
|
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-right");
|
||||||
// ...as the artboard's three cards: zoom; the view (compass, north lock, 3D,
|
// ...as the artboard's three cards: zoom; the view (compass, north lock, 3D,
|
||||||
// my position); the tools (measure, note, home). Each control keeps its own
|
// my position); the tools (measure, note, home). Each control keeps its own
|
||||||
@@ -581,36 +582,71 @@ Promise.allSettled(ready).then(() => {
|
|||||||
else map.once("idle", restore);
|
else map.once("idle", restore);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Alt+click, right click or a long press (touch browsers fire
|
// Right click, a long press (touch browsers fire contextmenu for it) or
|
||||||
// contextmenu for it) anywhere shows every rendered feature at that point — base map
|
// Alt+click: what's here (the Design canvas' Desktop). The position on top,
|
||||||
// (OSM tags via OpenFreeMap/protomaps), GPX/FIT layers, radar, all of it —
|
// a click copies it; Route here / Add to the trip / Save a point; every
|
||||||
// with its raw properties, inspired by NPMap4's infoboxControl (a generic
|
// rendered feature's raw properties folded under it (the debug view it
|
||||||
// "show me everything here" debug view, kept separate from the curated
|
// was). C copies the position under the mouse with no popup.
|
||||||
// popups those same features already have via their own layer-specific
|
const copyPosition = async ({ lng, lat }) => {
|
||||||
// click handlers, e.g. gpx.js's waypoint popups — both can fire on the same
|
try {
|
||||||
// click, which is fine, this is a power-user/debugging affordance, not
|
await navigator.clipboard.writeText(`${lat.toFixed(6)}, ${lng.toFixed(6)}`);
|
||||||
// something replacing the normal popups). No dedicated UI for this
|
return true;
|
||||||
// deliberately — a keyboard-modified click needs no button, state, or
|
} catch {
|
||||||
// cursor change of its own.
|
return false; // clipboard API unavailable (an insecure context)
|
||||||
const inspect = (event) => {
|
}
|
||||||
|
};
|
||||||
|
const whatsHere = (event) => {
|
||||||
|
const { lngLat } = event;
|
||||||
const features = map.queryRenderedFeatures(event.point);
|
const features = map.queryRenderedFeatures(event.point);
|
||||||
if (features.length === 0) return;
|
const rows = features
|
||||||
|
|
||||||
const html = features
|
|
||||||
.map((feature) => {
|
.map((feature) => {
|
||||||
const rows = Object.entries(feature.properties)
|
const cells = Object.entries(feature.properties)
|
||||||
.map(([key, value]) => `<tr><th>${escapeHtml(key)}</th><td>${escapeHtml(String(value))}</td></tr>`)
|
.map(([key, value]) => `<tr><th>${escapeHtml(key)}</th><td>${escapeHtml(String(value))}</td></tr>`)
|
||||||
.join("");
|
.join("");
|
||||||
return `<div class="debug-popup__feature"><strong>${escapeHtml(feature.layer.id)}</strong><table>${rows || "<tr><td>(no properties)</td></tr>"}</table></div>`;
|
return `<div class="debug-popup__feature"><strong>${escapeHtml(feature.layer.id)}</strong><table>${cells || "<tr><td>(no properties)</td></tr>"}</table></div>`;
|
||||||
})
|
})
|
||||||
.join("");
|
.join("");
|
||||||
|
const el = document.createElement("div");
|
||||||
new Popup({ maxWidth: "320px", className: "debug-popup" }).setLngLat(event.lngLat).setHTML(html).addTo(map);
|
el.className = "here";
|
||||||
|
el.innerHTML = `
|
||||||
|
<button type="button" class="here__position" title="Copy">
|
||||||
|
<span><b>${lngLat.lat.toFixed(5)}, ${lngLat.lng.toFixed(5)}</b><small>${formatCoords(lngLat.lat, lngLat.lng)}<span class="here__alt"></span></small></span>
|
||||||
|
<em>Copy</em>
|
||||||
|
</button>
|
||||||
|
<div class="here__actions">
|
||||||
|
<button type="button" data-do="route">Route here</button>
|
||||||
|
<button type="button" data-do="trip">Add to the trip</button>
|
||||||
|
${notesControl ? `<button type="button" data-do="note">Save a point</button>` : ""}
|
||||||
|
</div>
|
||||||
|
<details class="here__features"><summary>${features.length} feature${features.length === 1 ? "" : "s"} here</summary>${rows}</details>
|
||||||
|
<div class="here__hint">C copies the position under the cursor</div>`;
|
||||||
|
const popup = new Popup({ maxWidth: "320px", className: "debug-popup here-popup" }).setLngLat(lngLat).setDOMContent(el).addTo(map);
|
||||||
|
elevationAt(lngLat.lng, lngLat.lat, terrainOffline)
|
||||||
|
.then((metres) => metres != null && (el.querySelector(".here__alt").textContent = ` · ${Math.round(metres)} m`))
|
||||||
|
.catch(() => {});
|
||||||
|
el.querySelector(".here__position").addEventListener("click", async () => {
|
||||||
|
if (await copyPosition(lngLat)) el.querySelector(".here__position em").textContent = "Copied ✓";
|
||||||
|
});
|
||||||
|
const at = [lngLat.lng, lngLat.lat];
|
||||||
|
const actions = { route: () => addRoutePoint(at, null), trip: () => routePanel.addStop(at), note: () => notesControl.placeAt(lngLat) };
|
||||||
|
el.querySelector(".here__actions").addEventListener("click", (e) => {
|
||||||
|
const action = actions[e.target.dataset?.do];
|
||||||
|
if (!action) return;
|
||||||
|
popup.remove();
|
||||||
|
action();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
map.on("click", (event) => event.originalEvent.altKey && inspect(event));
|
map.on("click", (event) => event.originalEvent.altKey && whatsHere(event));
|
||||||
map.on("contextmenu", (event) => {
|
map.on("contextmenu", (event) => {
|
||||||
event.originalEvent.preventDefault();
|
event.originalEvent.preventDefault();
|
||||||
inspect(event);
|
whatsHere(event);
|
||||||
|
});
|
||||||
|
let mouseAt = null;
|
||||||
|
map.on("mousemove", ({ lngLat }) => (mouseAt = lngLat));
|
||||||
|
map.getCanvasContainer().addEventListener("mouseleave", () => (mouseAt = null));
|
||||||
|
document.addEventListener("keydown", async (e) => {
|
||||||
|
if (e.key !== "c" || !mouseAt || e.ctrlKey || e.altKey || e.metaKey || e.target.closest("input, textarea, select, [contenteditable]")) return;
|
||||||
|
if (await copyPosition(mouseAt)) cursorLabel.textContent = "Copied ✓";
|
||||||
});
|
});
|
||||||
|
|
||||||
// Feature properties can come straight from an uploaded GPX/FIT file (an
|
// Feature properties can come straight from an uploaded GPX/FIT file (an
|
||||||
|
|||||||
@@ -342,6 +342,14 @@ export class NotesControl {
|
|||||||
return this._container;
|
return this._container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "Save a point" from what's here (map.js): the note's form at that spot.
|
||||||
|
placeAt(lngLat) {
|
||||||
|
if (!this._active) this._setActive(true);
|
||||||
|
this._form.close();
|
||||||
|
this._removeMarker();
|
||||||
|
this._onClick({ lngLat });
|
||||||
|
}
|
||||||
|
|
||||||
_removeMarker() {
|
_removeMarker() {
|
||||||
this._marker?.remove();
|
this._marker?.remove();
|
||||||
this._marker = null;
|
this._marker = null;
|
||||||
|
|||||||
@@ -126,12 +126,12 @@ class RoutingTest < Minitest::Test
|
|||||||
def test_route_picks_the_costing_by_weight_and_returns_a_line
|
def test_route_picks_the_costing_by_weight_and_returns_a_line
|
||||||
shape = "wdg|xA{ubdQc@w@"
|
shape = "wdg|xA{ubdQc@w@"
|
||||||
reply = JSON.generate(trip: { summary: { length: 1.5, time: 90 },
|
reply = JSON.generate(trip: { summary: { length: 1.5, time: 90 },
|
||||||
legs: [{ shape: shape, summary: { length: 1.5, time: 90 }, maneuvers: [{ instruction: "Drive north.", length: 1.5, type: 2, street_names: ["Main"] }] }] })
|
legs: [{ shape: shape, summary: { length: 1.5, time: 90 }, maneuvers: [{ instruction: "Drive north.", length: 1.5, type: 2, street_names: ["Main"], verbal_pre_transition_instruction: "Drive north on Main." }] }] })
|
||||||
# The per-country lookup failing (400) leaves the route as it is.
|
# The per-country lookup failing (400) leaves the route as it is.
|
||||||
request = serve_once("HTTP/1.1 200 OK\r\nContent-Length: #{reply.bytesize}\r\n\r\n#{reply}", "HTTP/1.1 400 Bad Request\r\nContent-Length: 2\r\n\r\n{}") do |url|
|
request = serve_once("HTTP/1.1 200 OK\r\nContent-Length: #{reply.bytesize}\r\n\r\n#{reply}", "HTTP/1.1 400 Bad Request\r\nContent-Length: 2\r\n\r\n{}") do |url|
|
||||||
route = Maptool::Routing.route(url, [[9.52, 47.14], [9.53, 47.15]], Maptool::Routing::DEFAULT_VEHICLES[1])
|
route = Maptool::Routing.route(url, [[9.52, 47.14], [9.53, 47.15]], Maptool::Routing::DEFAULT_VEHICLES[1])
|
||||||
assert_equal [2, "auto", "Drive north."], [route[:geometry][:coordinates].size, route[:properties][:costing], route[:properties][:maneuvers][0][:text]]
|
assert_equal [2, "auto", "Drive north."], [route[:geometry][:coordinates].size, route[:properties][:costing], route[:properties][:maneuvers][0][:text]]
|
||||||
assert_equal({ text: "Drive north.", km: 1.5, type: 2, street: "Main" }, route[:properties][:maneuvers][0])
|
assert_equal({ text: "Drive north.", km: 1.5, type: 2, street: "Main", say: "Drive north on Main." }, route[:properties][:maneuvers][0])
|
||||||
assert_equal [[1.5], [90]], route[:properties].values_at(:legs_km, :legs_s) # each leg's km and time, for the stops
|
assert_equal [[1.5], [90]], route[:properties].values_at(:legs_km, :legs_s) # each leg's km and time, for the stops
|
||||||
end
|
end
|
||||||
assert_includes request, %("costing_options":{"auto":{"height":3.0,"width":2.3}})
|
assert_includes request, %("costing_options":{"auto":{"height":3.0,"width":2.3}})
|
||||||
|
|||||||
Reference in new issue
Block a user