diff --git a/public/css/style.css b/public/css/style.css index 71c3658..104ac7c 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -4161,7 +4161,212 @@ html.follow-3d .maplibregl-ctrl-overview-map { display: none; } flex: none; } -.onthemap-map .overlays-panel__group { +.onthemap-map { + padding: 0 12px; +} + +/* ---- On the map, as on the artboard: section titles as small caps on the + panel's own white (no gray bands), compact rows — icon, a bold name with + a line under it, the value or the eye (● on, ○ off) at the right. */ +.overlays-panel__group, +.onthemap-map .overlays-panel__group, +.overlays-panel__group:first-child { + margin: 14px 0 2px; + padding: 0 4px; + border: none; + background: none; + font-size: 12px; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--ui-muted); +} + +.overlays-panel__list { + padding-top: 0; +} + +.overlays-panel__item + .overlays-panel__item { + box-shadow: none; +} + +.overlays-panel__row, +.overlays-panel__item > label { + gap: 10px; +} + +.overlays-panel__name, +.overlays-panel__item label { + font-size: 15px; + font-weight: 600; +} + +/* the checkbox drawn as the artboard's eye, at the row's end */ +.overlays-panel__toggle { + order: 99; + margin-left: auto; + flex: none; + appearance: none; + width: 20px; + height: 20px; + border: 2px solid var(--ui-muted); + border-radius: 50%; + background: none; + cursor: pointer; +} + +.overlays-panel__toggle:checked { + border-color: var(--accent); + background: var(--accent); + box-shadow: inset 0 0 0 3px var(--ui-bg); +} + +.overlays-panel__toggle:disabled { + opacity: 0.35; + cursor: default; +} + +.onthemap-row { + display: flex; + align-items: center; + gap: 10px; + min-height: 48px; + padding: 0 4px; +} + +.onthemap-row__icon { + width: 24px; + flex: none; + text-align: center; + font-size: 17px; + color: var(--ui-muted); +} + +.onthemap-row__text { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + color: var(--ui-fg); + text-decoration: none; +} + +.onthemap-row__text b { + font-size: 15px; +} + +.onthemap-row__text small { + font-size: 12px; + color: var(--ui-muted); +} + +/* Online | Offline, a segmented switch */ +.onthemap-seg { + display: flex; + border: 1px solid var(--ui-line); + border-radius: 6px; + overflow: hidden; +} + +.onthemap-seg[hidden] { + display: none; +} + +.basemap-panel .onthemap-seg .basemap-panel__option { + min-height: 30px; + height: 30px; margin: 0; - border-top: none; + padding: 0 10px; + border: none; + border-radius: 0; + background: none; + color: var(--ui-muted); + font-size: 13px; + font-weight: 600; +} + +.basemap-panel .onthemap-seg .basemap-panel__option.active { + background: var(--accent-bg); + color: var(--accent); +} + +.basemap-panel .onthemap-theme { + min-height: 30px; + border: none; + background: none; + color: var(--accent); + font-size: 13px; + font-weight: 600; + cursor: pointer; +} + +/* The map's buttons in the artboard's three cards (map.js): the controls + inside lose their own card look. */ +.map-card { + display: flex; + flex-direction: column; + border-radius: 8px; + background: var(--ui-bg); + box-shadow: 0 1px 6px rgb(0 0 0 / 0.25); + overflow: hidden; +} + +.map-card > .maplibregl-ctrl, +.map-card > .maplibregl-ctrl-group { + margin: 0; + border-radius: 0; + box-shadow: none; + background: none; +} + +.map-card > * + * { + border-top: 1px solid var(--ui-line); +} + +.map-card > .maplibregl-ctrl-compass { + width: 40px; + height: 40px; + border: none; + background-color: transparent; +} + +.map-card button { + width: 40px; + height: 40px; +} + +/* the overview map below the cards, smaller */ +.maplibregl-ctrl-top-right .maplibregl-ctrl-overview-map { + margin-top: 4px; +} + +/* topbar: offline state as a pill, Drive filled */ +.topbar .topbar__offline-status { + width: auto; + height: auto; + padding: 3px 9px; + border-radius: 10px; + background: rgb(255 255 255 / 0.1); + color: #bdbab0; + font-size: 12px; + white-space: nowrap; +} + +.topbar .topbar__offline-status::before { + content: "● "; +} + +.topbar .topbar__offline-status--ready { + color: #a5b84f; +} + +.topbar__drive { + border-color: var(--accent); + background: var(--accent); + color: #fff; +} + +.onthemap-row .basemap-panel__link { + padding: 0; + min-height: 0; } diff --git a/public/js/map.js b/public/js/map.js index c04dcda..9e0af5c 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -30,6 +30,7 @@ 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"; +import { elevationAt } from "/js/dem.js"; const CENTER = [17.1077, 48.1486]; const ZOOM = 13; @@ -286,11 +287,39 @@ map.addControl(new MeasureControl(), "top-right"); // upload/new-folder buttons. if (isLoggedIn()) map.addControl(new NotesControl(), "top-right"); map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-right"); +// ...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 +// container (their popovers hang off it), the card only groups them. +{ + const corner = map.getContainer().querySelector(".maplibregl-ctrl-top-right"); + const [nav, ...rest] = corner.children; + const card = (...controls) => { + const div = document.createElement("div"); + div.className = "maplibregl-ctrl map-card"; + div.append(...controls); + corner.appendChild(div); + return div; + }; + const view = card(...rest.slice(0, 3)); + view.prepend(nav.querySelector(".maplibregl-ctrl-compass")); + card(...rest.slice(3)); +} // 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)}`)); +let terrainOffline = false; // set once /api/terrain-tiles answers (below) +let elevationTimer = null; +map.on("mousemove", ({ lngLat }) => { + const at = `Cursor ${formatCoords(lngLat.lat, lngLat.lng)}`; + cursorLabel.textContent = at; + // the ground's height there, once the mouse rests a moment + clearTimeout(elevationTimer); + elevationTimer = setTimeout(async () => { + const metres = await elevationAt(lngLat.lng, lngLat.lat, terrainOffline).catch(() => null); + if (metres != null && cursorLabel.textContent === at) cursorLabel.textContent = `${at} · ${Math.round(metres)} m`; + }, 150); +}); map.getCanvasContainer().addEventListener("mouseleave", () => (cursorLabel.textContent = "")); const zoomLabel = document.querySelector(".statusbar__zoom"); const updateZoom = () => (zoomLabel.textContent = `Zoom ${map.getZoom().toFixed(1)}`); @@ -392,6 +421,9 @@ const NIGHT_MODES = { off: ["☀", "Night mode: off"], }; const nightButton = document.querySelector(".topbar__night"); +// On the map's Theme row: the same cycle as the topbar's button +const themeButton = document.querySelector(".onthemap-theme"); +themeButton.addEventListener("click", () => nightButton.click()); const nightMap = new NightMap(map); // The base style's texture patterns (grass, scrub, military hatch) and the // peak triangle are drawn at runtime rather than shipped in a sprite @@ -431,6 +463,7 @@ const updateNight = () => { else delete document.documentElement.dataset.palette; nightMap.set(dark); [nightButton.textContent, nightButton.title] = NIGHT_MODES[nightMode] || NIGHT_MODES.auto; + themeButton.textContent = `${{ auto: "Auto", on: "Night", dusk: "Dusk", off: "Day" }[nightMode] || "Auto"} ›`; }; nightButton.addEventListener("click", () => { const modes = Object.keys(NIGHT_MODES); @@ -509,6 +542,7 @@ ready.push(fetch("/api/offline-tiles") offlineStatus.hidden = false; offlineStatus.classList.toggle("topbar__offline-status--ready", available); offlineStatus.title = available ? "Offline map data ready" : "No offline map data on this server"; + offlineStatus.textContent = available ? "Offline ready" : "Online only"; }) .catch(() => { // Backend check failed; keep the online style and leave the switch as @@ -519,6 +553,7 @@ ready.push(fetch("/api/offline-tiles") ready.push(fetch("/api/terrain-tiles") .then((response) => response.json()) .then(({ available }) => { + terrainOffline = available; overlaysControl.setHillshadeOfflineAvailable(available); overlaysControl.setShadowOfflineAvailable(available); }) diff --git a/views/index.erb b/views/index.erb index acb83aa..2b5e578 100644 --- a/views/index.erb +++ b/views/index.erb @@ -73,18 +73,22 @@ offline one (LayerToggleControl, map.js) — then the overlays. -->
Map
-
- - +
+ + Maponline or this server's offline map + + + +
-
- Legend & symbols ↗ +
+ + Themeday / dusk / night, auto by the sun + +
+