Home button fits all of Slovakia; add an overview map, top-right
CI / check (push) Successful in 1m33s
CI / deploy (push) Successful in 27s

Home now fitBounds()s a country-wide bbox instead of resetting to
CENTER/ZOOM's Bratislava point, since Home resetting into the same
city you'd already be looking at wasn't useful.

The overview map is NPS's own overview plugin (npmap5-plugins, still
on an unmerged branch), vendored and converted from its UMD dist
build to a plain ES module. Patched one MapLibre API break found while
verifying it: the plugin reads map.transform (public in the MapLibre
~2.4 it targets) to relax the inset's polar pan limit; MapLibre 6 (this
app's vendored version) no longer exposes .transform at all, so it
threw on load. Guarded to skip that cosmetic adjustment when absent
instead.
This commit is contained in:
randy committed 2026-09-07 22:30:56 +02:00
1 parent ddf2ee4990
commit 96065b1237
7 files changed
+441 -31

No files matched your search

+29 -15
View File
@@ -137,26 +137,40 @@ Now that any view can be the starting one (via that permalink), a way
back to the app's actual default is worth having: a "Home" button
(`public/vendor/npmap-home-button/`, the National Park Service's own
`home-button` MapLibre control — see `docs/third-party-notices.adoc`)
sits top-left on the map, pinned to `CENTER`/`ZOOM` explicitly rather
than its own fallback (the view at construction time, which would just
be wherever a loaded permalink happened to point). It resets to the
app's default view, not the visitor's own location — that's
`GeolocateControl`, a separate button in the same stack (below).
sits top-left on the map. It fits to `SLOVAKIA_BOUNDS` (a country-wide
bounding box) rather than the plain `CENTER`/`ZOOM` point the map
itself starts at — "home" is meant as a full-country overview, not a
re-centering on Bratislava. It resets to that fixed default view, not
the visitor's own location — that's `GeolocateControl`, a separate
button in the same stack (below).
That Home button is the top of a small top-left stack — Home, zoom
in/out (`NavigationControl`, `showCompass: false` since this map never
rotates), a passive zoom-level readout (`ZoomLevelControl`, a plain div
updated on the map's `zoom` event — not a button, since it has no
click behavior of its own), locate-me (`GeolocateControl`), and a
"Base map" button — matching the National Park Service's own map
control layout (grouped
together on the map itself, rather than split across corners or
between the map and a side panel). The last of those,
`MapLayersButton` (`public/js/map.js`), is a second entry point into
the exact same Online/Offline panel `LayerToggleControl` already
manages in the page's own sidebar — both call the same
`LayerToggleControl#toggle()`, so there's one source of truth for the
panel's open/closed state either way.
click behavior of its own), a distance/area measuring tool
(`MeasureControl`, `public/js/measure.js`), locate-me
(`GeolocateControl`), and a "Base map" button — matching the National
Park Service's own map control layout (grouped together on the map
itself, rather than split across corners or between the map and a side
panel). The last of those, `MapLayersButton` (`public/js/map.js`), is
a second entry point into the exact same Online/Offline panel
`LayerToggleControl` already manages in the page's own sidebar — both
call the same `LayerToggleControl#toggle()`, so there's one source of
truth for the panel's open/closed state either way.
A separate control sits top-right: a small inset overview map
(`public/vendor/npmap-overview/`, NPS's `overview` plugin — see
`docs/nps-resources.adoc`) showing the current view's location in a
wider, zoomed-out context, with the visible area drawn as a box on top
of it; dragging that box pans the main map. It clones whichever base
style the main map is currently showing (`style: ''`, its own default —
the plugin reads `map.style.serialize()`) rather than a separate style
of its own, so it stays visually consistent with the Online/Offline
toggle without this app maintaining a second style for it. Vendored
from an unmerged upstream branch and patched for a MapLibre API break
(it targeted MapLibre ~2.4's public `map.transform`, since removed) —
see `docs/third-party-notices.adoc` for the exact patch.
=== Debug inspector (Alt+click)
+13 -8
View File
@@ -27,6 +27,10 @@ checking here before searching from zero next time.
| Park Tiles color palette (offline basemap theme)
| `public/js/map.js`'s `OFFLINE_THEME`
| Colors only — see <<park-tiles>> for why the actual tile service isn't used
| `overview` (top-right minimap/inset control)
| `public/vendor/npmap-overview/`
| MIT (per that branch's `package.json`); same public-domain repo as above
|===
See `docs/third-party-notices.adoc` for the formal vendored-library
@@ -99,18 +103,19 @@ https://github.com/nationalparkservice/npmap5-plugins/issues/7[#7].
=== On unmerged feature branches (less vetted — not on `main` yet)
`overview` (branch `maplibre-gl-overview`) has since been adopted —
see "What this app actually uses" above and
`docs/architecture.adoc`'s control-stack section. Live demo (as
upstream ships it, unpatched):
https://raw.githack.com/nationalparkservice/npmap5-plugins/maplibre-gl-overview/examples/index.html.
Note: MapLibre GL JS has no first-party minimap of its own — this
isn't more "official" than any other third-party minimap plugin, just
NPS-flavored.
[cols="1,3"]
|===
| Plugin | What it is
| `overview` (branch `maplibre-gl-overview`)
| A minimap/inset control, any corner, respects pitch/bearing. Live
demo: https://raw.githack.com/nationalparkservice/npmap5-plugins/maplibre-gl-overview/examples/index.html.
Note: MapLibre GL JS has no first-party minimap of its own — this
wouldn't be more "official" than any other third-party minimap
plugin, just NPS-flavored. No minimap has been requested for this
app; would be a nice-to-have, not a fix for anything.
| `carto` (branch `maplibre-gl-carto-source`)
| Adds a vector-tile source backed by Carto.com-hosted data. Only
useful if we actually have a Carto-hosted dataset to point at — we
+13
View File
@@ -36,8 +36,21 @@ required):
| NPS Home Button (`home-button`)
| 0.0.1-d
| https://github.com/nationalparkservice/npmap5-plugins/tree/main/home-button
| NPS Overview Map (`maplibre-gl-overview`)
| 5.0.1
| https://github.com/nationalparkservice/npmap5-plugins/tree/maplibre-gl-overview
|===
The overview map is vendored from an unmerged branch, not `main` (see
`docs/nps-resources.adoc`), and converted from its UMD dist build to a
plain ES module — no functional change except the module wrapper. It
was also patched for a MapLibre API break: it reads `map.transform`
(public in the MapLibre ~2.4 this plugin targets) to relax the
overview's polar pan limit, but MapLibre 6's `Map` no longer exposes
`.transform` at all — guarded to skip that (cosmetic) adjustment
instead of throwing when it's absent.
Offline map text labels need font glyphs too (see
`docs/architecture.adoc`), vendored under `public/vendor/fonts/` —
SIL Open Font License, not BSD-3-Clause like the above: