Desktop redesign after the Design canvas' Desktop artboard: search is one field in the topbar (places, the library, coordinates; / focuses it, sources and results drop down under it), the side rail is labelled (Map, Overlays, Library, Import | Route, Offline | GNSS, Live, Status at the bottom), the map's buttons in one column on the right (zoom and compass, north lock, 3D, my position, measure, note, home; measure/note panels open to the left), a status bar under the map (center coordinates to copy, the point under the mouse, zoom, scale, revision) instead of the zoom-level control, the scale on the map and the coordinates in the topbar; the base map button on the map dropped (the rail has it). Route panel reordered: points with their legs, adding one, the totals as a card, vehicle and avoid, directions and reach folded, reverse/clear/save last. Drive unchanged: the search, the status bar and the right column hide there
This commit is contained in:
1 parent
60d7c825fc
commit
0a5548cd8f
4 files changed
+252
-214
No files matched your search
+42
-111
@@ -142,12 +142,6 @@ class LayerToggleControl {
|
||||
if (open) notifySidePanelOpen(this._panel);
|
||||
}
|
||||
|
||||
// Public wrapper so a second entry point (MapLayersButton, a map corner
|
||||
// control) can open/close the same panel without reaching into a
|
||||
// "private" method by convention only.
|
||||
toggle() {
|
||||
this._togglePanel();
|
||||
}
|
||||
|
||||
setActive(name) {
|
||||
this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => {
|
||||
@@ -164,71 +158,6 @@ class LayerToggleControl {
|
||||
}
|
||||
}
|
||||
|
||||
// A small map-corner button (grouped with Home/zoom, see below) that's a
|
||||
// second entry point to the same panel LayerToggleControl already manages
|
||||
// in the page's own sidebar — matching the National Park Service's own
|
||||
// map control layout, which keeps zoom/home/base-map together on the map
|
||||
// rather than split between the map and a separate side rail.
|
||||
class MapLayersButton {
|
||||
constructor(layerToggle) {
|
||||
this._layerToggle = layerToggle;
|
||||
}
|
||||
|
||||
onAdd() {
|
||||
this._container = document.createElement("div");
|
||||
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group";
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.title = "Base map";
|
||||
button.setAttribute("aria-label", "Base map");
|
||||
button.innerHTML = LAYERS_ICON;
|
||||
button.addEventListener("click", () => this._layerToggle.toggle());
|
||||
this._container.appendChild(button);
|
||||
return this._container;
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this._container.remove();
|
||||
}
|
||||
|
||||
getDefaultPosition() {
|
||||
return "top-left";
|
||||
}
|
||||
}
|
||||
|
||||
// A passive zoom-level readout, sitting in the same stack as the buttons
|
||||
// around it — the National Park Service's own control layout has one (the
|
||||
// small numbered square next to their zoom buttons). Not a button: no
|
||||
// click behavior, just a live display, so it's a plain div rather than a
|
||||
// <button> (no hover/focus affordance implying it does something).
|
||||
class ZoomLevelControl {
|
||||
onAdd(map) {
|
||||
this._map = map;
|
||||
this._container = document.createElement("div");
|
||||
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group zoom-level-ctrl";
|
||||
this._label = document.createElement("div");
|
||||
this._label.className = "zoom-level-ctrl__value";
|
||||
this._container.appendChild(this._label);
|
||||
|
||||
this._update = () => {
|
||||
this._label.textContent = Math.round(map.getZoom());
|
||||
};
|
||||
this._update();
|
||||
map.on("zoom", this._update);
|
||||
|
||||
return this._container;
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this._map.off("zoom", this._update);
|
||||
this._container.remove();
|
||||
}
|
||||
|
||||
getDefaultPosition() {
|
||||
return "top-left";
|
||||
}
|
||||
}
|
||||
|
||||
// Tilts the camera between a flat top-down view and a fixed 3D-perspective
|
||||
// pitch — bearing stays untouched, so this is purely "look at it from an
|
||||
// angle", not a rotate/compass control. Tilted, the ground is raised into
|
||||
@@ -341,13 +270,7 @@ const map = new MaplibreMap({
|
||||
hash: "map",
|
||||
});
|
||||
|
||||
// A compact top-left stack — Home, zoom, zoom-level readout, measure,
|
||||
// locate-me, base map — matching the National Park Service's own map
|
||||
// control layout,
|
||||
// all grouped together rather than split across corners. Added in this
|
||||
// order since MapLibre stacks same-position controls in add order.
|
||||
//
|
||||
// bounds (rather than homePosition/zoom) so Home resets to an overview of
|
||||
// Home's bounds (rather than homePosition/zoom) so Home resets to an overview of
|
||||
// the whole country, not back to CENTER/ZOOM's initial Bratislava view —
|
||||
// now that the URL hash can restore any view on load (see the Hash option
|
||||
// above), "current view" and "the default view" are no longer the same
|
||||
@@ -358,21 +281,17 @@ const SLOVAKIA_BOUNDS = [
|
||||
[16.83, 47.73],
|
||||
[22.57, 49.61],
|
||||
];
|
||||
// The Design canvas' Desktop: search in the topbar, the map's own buttons
|
||||
// in one column on the right — zoom and compass, the view (north lock, 3D,
|
||||
// my position), the tools (measure, note, home); the zoom level, the scale
|
||||
// and the coordinates in the status bar under the map.
|
||||
const searchControl = new SearchControl();
|
||||
map.addControl(searchControl, "top-left");
|
||||
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-left");
|
||||
searchControl.mount(map, document.querySelector(".topbar__search"));
|
||||
// The compass shows the bearing; a click turns the map back north.
|
||||
map.addControl(new NavigationControl({ visualizePitch: false }), "top-left");
|
||||
map.addControl(new RotationLockControl(), "top-left");
|
||||
map.addControl(new ZoomLevelControl(), "top-left");
|
||||
map.addControl(new NavigationControl({ visualizePitch: false }), "top-right");
|
||||
map.addControl(new RotationLockControl(), "top-right");
|
||||
const pitchToggle = new PitchToggleControl();
|
||||
map.addControl(pitchToggle, "top-left");
|
||||
map.addControl(new MeasureControl(), "top-left");
|
||||
// Writing a note needs a login (POST /api/library/notes) — no point adding a
|
||||
// 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
|
||||
// upload/new-folder buttons.
|
||||
if (isLoggedIn()) map.addControl(new NotesControl(), "top-left");
|
||||
map.addControl(pitchToggle, "top-right");
|
||||
// Constructed here (rather than down where it's mounted, alongside the
|
||||
// other sidebar controls) so LocateControl can hold the same instance —
|
||||
// its constructor only touches `map`, mount() (which needs the sidebar
|
||||
@@ -384,8 +303,25 @@ const gnssControl = new GnssControl(map);
|
||||
// device's separate, often less accurate location service, but only once
|
||||
// the "GNSS" sidebar icon actually turns it on — not just whenever a
|
||||
// receiver happens to have a fix. See locate.js.
|
||||
map.addControl(new LocateControl(gnssControl), "top-left");
|
||||
map.addControl(new ScaleControl({ unit: "metric" }), "bottom-left");
|
||||
map.addControl(new LocateControl(gnssControl), "top-right");
|
||||
map.addControl(new MeasureControl(), "top-right");
|
||||
// Writing a note needs a login (POST /api/library/notes) — no point adding a
|
||||
// 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
|
||||
// upload/new-folder buttons.
|
||||
if (isLoggedIn()) map.addControl(new NotesControl(), "top-right");
|
||||
map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-right");
|
||||
|
||||
// The status bar: the map's center (click to copy), the point under the
|
||||
// mouse, the zoom level, the scale.
|
||||
const cursorLabel = document.querySelector(".statusbar__cursor");
|
||||
map.on("mousemove", ({ lngLat }) => (cursorLabel.textContent = `Cursor ${formatCoords(lngLat.lat, lngLat.lng)}`));
|
||||
map.getCanvasContainer().addEventListener("mouseleave", () => (cursorLabel.textContent = ""));
|
||||
const zoomLabel = document.querySelector(".statusbar__zoom");
|
||||
const updateZoom = () => (zoomLabel.textContent = `Zoom ${map.getZoom().toFixed(1)}`);
|
||||
updateZoom();
|
||||
map.on("zoom", updateZoom);
|
||||
document.querySelector(".statusbar__scale").appendChild(new ScaleControl({ unit: "metric" }).onAdd(map));
|
||||
|
||||
// A small inset map showing where the current view sits in context — NPS's
|
||||
// own overview plugin (docs/nps-resources.adoc's "overview" entry, still on
|
||||
@@ -402,7 +338,7 @@ map.once("style.load", () => {
|
||||
map.addControl(new OverviewMapControl({}), "top-right");
|
||||
});
|
||||
|
||||
const coordsLabel = document.querySelector(".topbar__coords");
|
||||
const coordsLabel = document.querySelector(".statusbar__coords");
|
||||
const updateCoords = () => {
|
||||
const { lng, lat } = map.getCenter();
|
||||
coordsLabel.innerHTML = `<span class="topbar__icon">${WAYPOINT_ICON}</span><span>${formatCoords(lat, lng)}</span>`;
|
||||
@@ -535,19 +471,20 @@ setInterval(updateNight, 60000);
|
||||
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
|
||||
// Grouped into the TODO's planned 4-module menu (Explorer / Offline hub /
|
||||
// Navigation / Camper & HW) ahead of that split actually happening —
|
||||
// Camper & HW has no sidebar item yet (leveling/solar/telemetry are all
|
||||
// still unbuilt), so it's left out rather than shown empty.
|
||||
// The rail of the Design canvas' Desktop, labelled: what's on the map (the
|
||||
// map, overlays), the library and imports; the route; offline data; live
|
||||
// (GNSS, LiveTrack); Status pinned at the bottom. Folding Map, Overlays and
|
||||
// Live into one "On the map" panel is the canvas' next step, not done yet.
|
||||
const layerToggle = new LayerToggleControl(applyStyle);
|
||||
const profilePanel = new TrackProfilePanel(map);
|
||||
profilePanel.mount();
|
||||
|
||||
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Explorer"></div>`);
|
||||
const gpxPanel = new GpxPanelControl(map, profilePanel);
|
||||
gpxPanel.mount(sidebar);
|
||||
layerToggle.mount(sidebar);
|
||||
layerToggle.setActive("online");
|
||||
const overlaysControl = new OverlaysControl(map);
|
||||
overlaysControl.mount(sidebar);
|
||||
const gpxPanel = new GpxPanelControl(map, profilePanel);
|
||||
gpxPanel.mount(sidebar);
|
||||
offerSharedFiles(gpxPanel);
|
||||
searchControl.setLayerOpeners({
|
||||
layers: (path, result) => gpxPanel.showFeature(path, result.bbox.slice(0, 2)),
|
||||
@@ -558,29 +495,23 @@ pitchToggle.setOverlaysControl(overlaysControl);
|
||||
// "hide the write-only affordance" story as NotesControl above.
|
||||
if (isLoggedIn()) new PluginsControl(map).mount(sidebar);
|
||||
|
||||
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Offline hub"></div>`);
|
||||
layerToggle.mount(sidebar);
|
||||
layerToggle.setActive("online");
|
||||
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label"></div>`);
|
||||
const routePanel = new RoutePanelControl(map, gnssControl, profilePanel);
|
||||
routePanel.mount(sidebar);
|
||||
setupDriving(map, nightButton, routePanel);
|
||||
new OfflineDataControl().mount(sidebar);
|
||||
|
||||
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Navigation"></div>`);
|
||||
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label"></div>`);
|
||||
gnssControl.mount(sidebar);
|
||||
new LiveTrackPanelControl(map).mount(sidebar);
|
||||
|
||||
if (isLoggedIn()) new DebugControl().mount(sidebar);
|
||||
if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update"), document.querySelector(".debug-panel__update-check"));
|
||||
// A short name under each icon (CSS ::after), the title stays the tooltip.
|
||||
const RAIL_LABELS = { "Base map": "Map", "Tracks & Points": "Library", "Import plugins": "Import", "Offline data": "Offline", LiveTrack: "Live", "Status / debug": "Status" };
|
||||
sidebar.querySelectorAll(".sidebar-icon").forEach((icon) => (icon.dataset.label = RAIL_LABELS[icon.title] ?? icon.title));
|
||||
setupSidePanelModes();
|
||||
|
||||
// The sidebar already has a "Base map" icon (opens the same panel) —
|
||||
// this is a second entry point for it, grouped with Home/zoom on the map
|
||||
// itself rather than off in the page's own side rail, matching NPS's
|
||||
// layout. layerToggle only needs to exist (not be mounted yet) for this.
|
||||
const mapLayersButton = new MapLayersButton(layerToggle);
|
||||
map.addControl(mapLayersButton, "top-left");
|
||||
|
||||
function applyStyle(name) {
|
||||
layerToggle.setActive(name);
|
||||
map.setStyle(nightMap.base(name === "offline" ? offlineStyle() : onlineStyle()));
|
||||
|
||||
+25
-26
@@ -37,7 +37,7 @@ function formatKm(km) {
|
||||
return km < 10 ? `${km.toFixed(1)} km` : `${Math.round(km)} km`;
|
||||
}
|
||||
|
||||
// A place-name/coordinate search box, matching NPS's own Park Tiles viewer.
|
||||
// A place-name/coordinate search box in the topbar.
|
||||
// Every result says where it was found; picking one from a layer that's
|
||||
// currently switched off switches it on (see setLayerOpeners).
|
||||
export class SearchControl {
|
||||
@@ -53,16 +53,20 @@ export class SearchControl {
|
||||
this._openers = openers;
|
||||
}
|
||||
|
||||
onAdd(map) {
|
||||
// In the topbar (the Design canvas' Desktop): the field always there,
|
||||
// the sources and results drop down under it while it's in use; "/"
|
||||
// anywhere focuses it.
|
||||
mount(map, slot) {
|
||||
this._map = map;
|
||||
this._container = document.createElement("div");
|
||||
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group search-ctrl";
|
||||
this._container.className = "search-ctrl";
|
||||
this._container.innerHTML = `
|
||||
<button type="button" class="search-ctrl__button" title="Search" aria-label="Search">${SEARCH_ICON}</button>
|
||||
<form class="search-panel__form" role="search">
|
||||
<span class="search-ctrl__icon" aria-hidden="true">${SEARCH_ICON}</span>
|
||||
<input type="search" class="search-panel__input" placeholder="Search places, the library, or lat, lng" aria-label="Search">
|
||||
<kbd class="search-ctrl__key" title="Press / to search">/</kbd>
|
||||
</form>
|
||||
<div class="search-panel" hidden>
|
||||
<form class="search-panel__form">
|
||||
<input type="text" class="search-panel__input" placeholder="Search, or lat, lng">
|
||||
</form>
|
||||
<div class="search-panel__sources">
|
||||
${SOURCES.map(
|
||||
(source) => `
|
||||
@@ -73,12 +77,11 @@ export class SearchControl {
|
||||
<ul class="search-panel__results"></ul>
|
||||
</div>
|
||||
`;
|
||||
this._button = this._container.querySelector(".search-ctrl__button");
|
||||
this._panel = this._container.querySelector(".search-panel");
|
||||
this._input = this._container.querySelector(".search-panel__input");
|
||||
this._resultsEl = this._container.querySelector(".search-panel__results");
|
||||
|
||||
this._button.addEventListener("click", () => this._toggle());
|
||||
this._input.addEventListener("focus", () => (this._panel.hidden = false));
|
||||
this._container.querySelector(".search-panel__form").addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
this._search();
|
||||
@@ -90,23 +93,20 @@ export class SearchControl {
|
||||
if (this._input.value.trim()) this._search();
|
||||
});
|
||||
});
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!this._container.contains(event.target)) this._panel.hidden = true;
|
||||
});
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape" && this._container.contains(document.activeElement)) {
|
||||
this._panel.hidden = true;
|
||||
this._input.blur();
|
||||
} else if (event.key === "/" && !event.target.closest("input, textarea, select, [contenteditable]")) {
|
||||
event.preventDefault();
|
||||
this._input.focus();
|
||||
}
|
||||
});
|
||||
|
||||
return this._container;
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this._container.remove();
|
||||
}
|
||||
|
||||
getDefaultPosition() {
|
||||
return "top-left";
|
||||
}
|
||||
|
||||
_toggle() {
|
||||
const opening = this._panel.hidden;
|
||||
this._panel.hidden = !opening;
|
||||
this._button.classList.toggle("active", opening);
|
||||
if (opening) this._input.focus();
|
||||
slot.appendChild(this._container);
|
||||
}
|
||||
|
||||
async _search() {
|
||||
@@ -260,6 +260,5 @@ export class SearchControl {
|
||||
this._marker = new Marker({ element: el }).setLngLat(center).addTo(this._map);
|
||||
}
|
||||
this._panel.hidden = true;
|
||||
this._button.classList.remove("active");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user