Park Tiles look as the only base map theme: the old ONLINE_STYLE_PATCH palette and the theme switch are gone, the legend at /symbols.html shows the one look, and the docs carry the sampled Park Tiles colors
CI / check (push) Successful in 19s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-18 23:36:30 +01:00
1 parent 07b623b7ca
commit 59a29e86a5
8 files changed
+76 -227

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ independence from connectivity.
** [ ] OpenTopoMap-style `fill-pattern` texture for forest (tree icons) and meadow/pasture (grass texture) landcover, instead of flat fill colors — Liberty's own sprite (`public/vendor/liberty-sprite/`) only has a `wetland` dot pattern, no tree/grass, so this needs custom pattern images added to the sprite sheet; works offline and online alike since it's just a style/sprite change, unlike pulling in OpenTopoMap's own raster tiles (online-only, restrictive tile-usage policy, wouldn't match the NPS palette) ** [ ] OpenTopoMap-style `fill-pattern` texture for forest (tree icons) and meadow/pasture (grass texture) landcover, instead of flat fill colors — Liberty's own sprite (`public/vendor/liberty-sprite/`) only has a `wetland` dot pattern, no tree/grass, so this needs custom pattern images added to the sprite sheet; works offline and online alike since it's just a style/sprite change, unlike pulling in OpenTopoMap's own raster tiles (online-only, restrictive tile-usage policy, wouldn't match the NPS palette)
** [x] Elevation-tinted terrain — a `color-relief` layer (hypsometric tint, this app's own green→brown→gray palette) under the hillshade layer, same "Terrain shading" toggle ** [x] Elevation-tinted terrain — a `color-relief` layer (hypsometric tint, this app's own green→brown→gray palette) under the hillshade layer, same "Terrain shading" toggle
** [x] Road hierarchy: clearly distinguish paved roads from unpaved/gravel/track — critical for knowing if the camper can get there ** [x] Road hierarchy: clearly distinguish paved roads from unpaved/gravel/track — critical for knowing if the camper can get there
** [ ] Decide on a closer Park Tiles "Standard" look — undecided, it's lovely for US parks but doesn't necessarily suit European maps. Colors sampled from the Park Tiles legend swatches (`nps.gov/maps/web/img/legend/*-standard.png`): land `#F7EEE8`, NPS unit area a flat sage `#CED2B7`, boundary `#779238`/`#8BA35A` with a `#B2C294` tint band, water `#B5D0DE`, primary road `#F8ECBE` cased `#8F867A`, secondary `#F9F9F6`, local `#F5F3E5`, trails dashed `#8E827B`, buildings `#E7E4D5`/`#C1A88B`. A working MapLibre patch of Liberty (`parkTilesStyle()`, incl. moving the park fill above landcover) is in `~/Projects/NPS_Maps/index.html`. Note `ONLINE_STYLE_PATCH`'s current park green `#b3e378` is actually Park Tiles' park *point* color, not their area fill ** [x] Park Tiles "Standard" look as the base map — `PARK_TILES_PATCH` in `public/js/map_themes.js`, colors sampled from the Park Tiles legend swatches (values in `docs/nps-resources.adoc`): flat sage park areas above landcover with a tint band inside the boundary, cream land, Park Tiles road colors. Replaced the looser `ONLINE_STYLE_PATCH` palette (briefly both, switchable, to compare); map legend at `/symbols.html`
== Main menu reorganization (4 modules) == Main menu reorganization (4 modules)
+24 -29
View File
@@ -66,9 +66,9 @@ approximate the online look — two independently-maintained palettes
that drifted out of sync (building opacity, road casings, park that drifted out of sync (building opacity, road casings, park
boundaries) every time one side changed. Planetiler's default profile boundaries) every time one side changed. Planetiler's default profile
*is* OpenMapTiles, so `offlineStyle()` now just clones the same parsed *is* OpenMapTiles, so `offlineStyle()` now just clones the same parsed
Liberty JSON `ONLINE_STYLE` already fetched, repoints its `sources`, Liberty JSON `ONLINE_STYLE_TEMPLATE` already fetched, repoints its `sources`,
`glyphs`, and `sprite` at local copies, and applies the exact same `glyphs`, and `sprite` at local copies, and applies the exact same
`ONLINE_STYLE_PATCH` recolor (below) — one palette, one place to tune `patchOnlineStyle` recolor (below) — one palette, one place to tune
it, correct on both sides by construction rather than by re-checking it, correct on both sides by construction rather than by re-checking
every time something changes. every time something changes.
@@ -111,22 +111,25 @@ snapshot under `public/vendor/liberty-sprite/` — both `offlineStyle()`
and the online style otherwise share identical `glyphs`/`sprite` and the online style otherwise share identical `glyphs`/`sprite`
roles, just resolved to local vs. `tiles.openfreemap.org` URLs. roles, just resolved to local vs. `tiles.openfreemap.org` URLs.
`public/js/map_themes.js`'s `ONLINE_STYLE_PATCH` — applied to whichever `public/js/map_themes.js`'s `patchOnlineStyle` — applied to whichever
source is loaded, online or offline (see above) — nudges Liberty's source is loaded, online or offline (see above) — recolors Liberty's
OpenMapTiles layer ids towards a warm, National Park Service OpenMapTiles layer ids after the National Park Service's Park Tiles
"Park Tiles"-inspired look. A few of these values are the genuine "Standard" style (`PARK_TILES_PATCH`). Colors are sampled from the Park
paint colors pulled from a public Park Tiles style JSON Tiles legend swatches (`nps.gov/maps/web/img/legend/*-standard.png`)
(`nps.gov/lib/npmap.js/style/ck72fwp2642dv07o7tbqinvz4.json`, the plus the public "Imagery" style JSON
"Imagery" variant — the only one of NPS's four styles served from a (`nps.gov/lib/npmap.js/style/ck72fwp2642dv07o7tbqinvz4.json`, the only
plain, unauthenticated URL; "Standard"/"Slate"/"Light" resolve through one of NPS's four styles served from a plain, unauthenticated URL;
Mapbox Studio's private API with an access token, which isn't "Standard"/"Slate"/"Light" resolve through Mapbox Studio's private API
something to piggyback on even though it's technically visible in with an access token, which isn't something to piggyback on even though
their own JS bundle) — background, the park/protected-area green, the it's technically visible in their own JS bundle) — see
two road-importance tiers, and the park-boundary line color. The rest `docs/nps-resources.adoc` for the values. The park fill is moved above
are reasoned to match that same warm family (olive greens, muted blue, landcover, so a whole park reads as one flat sage like theirs, with a
brown road casings) rather than sourced. This is deliberately light-green tint band inside its boundary line; Natural Earth's
partial — labels, halos, rail, and minor overlays (cemetery/hospital/ low-zoom color relief is hidden. Line widths stay Liberty's own.
school/pitch/track shading) are left at Liberty's own defaults. `/symbols.html` draws its map legend from the same patched style.
(An earlier, looser "Park Tiles-inspired" palette, `ONLINE_STYLE_PATCH`,
was replaced by this one — it used Park Tiles' park *point* green
`#b3e378` as the area fill.)
+ +
Recreating the *color choices* is fine — that's not the kind of thing Recreating the *color choices* is fine — that's not the kind of thing
a data license restricts — but the actual Park Tiles *service* stays a data license restricts — but the actual Park Tiles *service* stays
@@ -137,19 +140,11 @@ labeling prioritized), not general-purpose worldwide cartography —
irrelevant to this app either way now, since it never talks to NPS's irrelevant to this app either way now, since it never talks to NPS's
tile service, only ever OpenFreeMap/Geofabrik. tile service, only ever OpenFreeMap/Geofabrik.
A second theme, *NPS Park Tiles* (Base map panel → Theme, remembered in
`localStorage`), is a closer take on Park Tiles' Standard style:
`PARK_TILES_PATCH` in the same file, colors sampled from the Park Tiles
legend swatches (see `docs/nps-resources.adoc`), and the park fill moved
above landcover with a tint band inside its boundary line. Both themes
live in `public/js/map_themes.js` so `/symbols.html` can draw its map
legend from the very same patched style the map uses.
`loadOnlineStyle` (`public/js/map.js`) fetches Liberty's live `loadOnlineStyle` (`public/js/map.js`) fetches Liberty's live
`style.json` once and keeps it unpatched as `ONLINE_STYLE_TEMPLATE`; `style.json` once and keeps it unpatched as `ONLINE_STYLE_TEMPLATE`;
`onlineStyle(theme)` patches a fresh copy for whichever theme is `onlineStyle()` patches a fresh copy for each `setStyle` — MapLibre
selected — MapLibre accepts a style object anywhere it accepts a style accepts a style object anywhere it accepts a style URL, so `applyStyle`'s
URL, so `applyStyle`'s `map.setStyle` takes either. `map.setStyle` takes either.
That fetch runs before the map (and the rest of the page) is That fetch runs before the map (and the rest of the page) is
constructed — a top-level `await` — so there's no flash of Liberty's constructed — a top-level `await` — so there's no flash of Liberty's
own colors before the patch lands; a 3s timeout and a catch-all fall own colors before the patch lands; a 3s timeout and a catch-all fall
+15 -9
View File
@@ -27,7 +27,7 @@ checking here before searching from zero next time.
public domain as a US government work public domain as a US government work
| Park Tiles color palette (shared offline + online basemap theme) | Park Tiles color palette (shared offline + online basemap theme)
| `public/js/map_themes.js`'s `ONLINE_STYLE_PATCH` | `public/js/map_themes.js`'s `PARK_TILES_PATCH`
| Colors only — see <<park-tiles>> for why the actual tile service isn't used | Colors only — see <<park-tiles>> for why the actual tile service isn't used
| `overview` (top-right minimap/inset control) | `overview` (top-right minimap/inset control)
@@ -187,8 +187,15 @@ why this app uses OpenFreeMap Liberty as its actual basemap, not Park
Tiles — see `docs/architecture.adoc`'s "Offline maps" section. Tiles — see `docs/architecture.adoc`'s "Offline maps" section.
Recreating the *color choices* is a different matter — not the kind of Recreating the *color choices* is a different matter — not the kind of
thing a data license restricts — and is what `ONLINE_STYLE_PATCH` in thing a data license restricts — and is what `PARK_TILES_PATCH` in
`public/js/map.js` actually does (see `docs/architecture.adoc`). `public/js/map_themes.js` actually does (see `docs/architecture.adoc`).
Its colors come from the Standard style's legend swatches
(`nps.gov/maps/web/img/legend/*-standard.png`, small rendered map
crops — sampled pixel by pixel): land `#F7EEE8`, NPS unit area a flat
sage `#CED2B7`, boundary `#779238`/`#8BA35A` with a `#B2C294` tint band,
water `#B5D0DE`, primary road `#F8ECBE` cased `#8F867A`, secondary
`#F9F9F6`, local `#F5F3E5`, trails dashed `#8E827B`, buildings
`#E7E4D5`/`#C1A88B`.
=== Public style JSON (source for the real colors we did pull) === Public style JSON (source for the real colors we did pull)
@@ -218,12 +225,11 @@ embedded credentials, even when technically reachable:
| `ck5cpia2u0auf01p9vbugvcpv` | `ck5cpia2u0auf01p9vbugvcpv`
|=== |===
Colors actually pulled from the Imagery style JSON and used in The Imagery style sits over satellite imagery, so it has no landcover
`ONLINE_STYLE_PATCH`: background (`hsl(40, 37%, 97%)`, a warm cream), the fills and white labels — useful for road/trail/boundary colors and label
park/protected-area green (`#b3e378`), the two road-importance tiers hierarchy, not for the land itself; those came from the legend swatches
(`#fdefbe`/`#fef7dd`), and the park-boundary line color (`#546619`, dark above. (Its `#b3e378` is the park *point* color, which an earlier palette
olive). The rest of `ONLINE_STYLE_PATCH` extends that same warm/olive mistakenly used as the park area fill.)
family by eye rather than from a sourced value.
=== Legend / cartographic hierarchy === Legend / cartographic hierarchy
-8
View File
@@ -586,14 +586,6 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr
padding: 6px; padding: 6px;
} }
.basemap-panel__heading {
padding: 8px 10px 2px;
font-size: 12px;
color: #666;
text-transform: uppercase;
letter-spacing: 0.04em;
}
.basemap-panel__link { .basemap-panel__link {
display: block; display: block;
padding: 10px; padding: 10px;
+18 -39
View File
@@ -43,7 +43,7 @@ const ONLINE_STYLE_URL = "https://tiles.openfreemap.org/styles/liberty";
// (a 3s timeout): this app is meant to work offline in the field, and // (a 3s timeout): this app is meant to work offline in the field, and
// blocking the entire page on a remote style server would undermine that // blocking the entire page on a remote style server would undermine that
// even though this particular fetch is only for the online map. // even though this particular fetch is only for the online map.
// Kept unpatched so either theme can be applied to a fresh copy (see onlineStyle()). // Kept unpatched; onlineStyle() patches a fresh copy for each setStyle.
async function loadOnlineStyle() { async function loadOnlineStyle() {
try { try {
const response = await fetch(ONLINE_STYLE_URL, { signal: AbortSignal.timeout(3000) }); const response = await fetch(ONLINE_STYLE_URL, { signal: AbortSignal.timeout(3000) });
@@ -55,19 +55,9 @@ async function loadOnlineStyle() {
const ONLINE_STYLE_TEMPLATE = await loadOnlineStyle(); const ONLINE_STYLE_TEMPLATE = await loadOnlineStyle();
// Base map state: which tiles (Online/Offline) and which color theme function onlineStyle() {
// (Maptool / NPS Park Tiles, remembered), see applyStyle().
let currentSource = "online";
let currentTheme = "maptool";
try {
if (localStorage.getItem("mapTheme") === "parktiles") currentTheme = "parktiles";
} catch {
// storage unavailable: default theme
}
function onlineStyle(theme) {
if (typeof ONLINE_STYLE_TEMPLATE === "string") return ONLINE_STYLE_TEMPLATE; if (typeof ONLINE_STYLE_TEMPLATE === "string") return ONLINE_STYLE_TEMPLATE;
return patchOnlineStyle(structuredClone(ONLINE_STYLE_TEMPLATE), theme); return patchOnlineStyle(structuredClone(ONLINE_STYLE_TEMPLATE));
} }
// A vendored copy of the same Liberty style ONLINE_STYLE_TEMPLATE fetches live // A vendored copy of the same Liberty style ONLINE_STYLE_TEMPLATE fetches live
@@ -83,14 +73,14 @@ const protocol = new pmtiles.Protocol();
addProtocol("pmtiles", protocol.tile); addProtocol("pmtiles", protocol.tile);
// Builds the offline style from OFFLINE_STYLE_TEMPLATE — the identical // Builds the offline style from OFFLINE_STYLE_TEMPLATE — the identical
// Liberty JSON + ONLINE_STYLE_PATCH recolor as the online map, just // Liberty JSON + patchOnlineStyle recolor (map_themes.js) as the online map, just
// repointed at a local PMTiles source instead of tiles.openfreemap.org. // repointed at a local PMTiles source instead of tiles.openfreemap.org.
// This works because data/offline.pmtiles is now built by Planetiler's own // This works because data/offline.pmtiles is now built by Planetiler's own
// OpenMapTiles profile (see docs/development.adoc), the same vector schema // OpenMapTiles profile (see docs/development.adoc), the same vector schema
// Liberty expects — before that, offline tiles used a different schema // Liberty expects — before that, offline tiles used a different schema
// (protomaps' own basemaps) needing a completely separate hand-tuned // (protomaps' own basemaps) needing a completely separate hand-tuned
// theme (protomaps-themes-base + OFFLINE_THEME) that could never be made // theme (protomaps-themes-base + OFFLINE_THEME) that could never be made
// to match ONLINE_STYLE_PATCH's look exactly, no matter how much either // to match the online look exactly, no matter how much either
// side got tuned. // side got tuned.
// //
// glyphs/sprite point at vendored local copies (public/vendor/fonts, // glyphs/sprite point at vendored local copies (public/vendor/fonts,
@@ -103,8 +93,8 @@ addProtocol("pmtiles", protocol.tile);
// this only ever silently fails to load at a zoom level offline users // this only ever silently fails to load at a zoom level offline users
// aren't in, the same graceful-degradation story as this app's other // aren't in, the same graceful-degradation story as this app's other
// online-only extras (Wikipedia, live radar). // online-only extras (Wikipedia, live radar).
function offlineStyle(theme) { function offlineStyle() {
const style = patchOnlineStyle(structuredClone(OFFLINE_STYLE_TEMPLATE), theme); const style = patchOnlineStyle(structuredClone(OFFLINE_STYLE_TEMPLATE));
style.sources.openmaptiles.url = `pmtiles://${window.location.origin}/tiles/offline.pmtiles`; style.sources.openmaptiles.url = `pmtiles://${window.location.origin}/tiles/offline.pmtiles`;
style.glyphs = `${window.location.origin}/vendor/fonts/{fontstack}/{range}.pbf`; style.glyphs = `${window.location.origin}/vendor/fonts/{fontstack}/{range}.pbf`;
style.sprite = `${window.location.origin}/vendor/liberty-sprite/ofm`; style.sprite = `${window.location.origin}/vendor/liberty-sprite/ofm`;
@@ -132,9 +122,8 @@ class LayerToggleControl {
.addEventListener("click", () => this._togglePanel(false)); .addEventListener("click", () => this._togglePanel(false));
this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => { this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => {
button.addEventListener("click", () => { button.addEventListener("click", () => {
this._onSelect({ source: button.dataset.style, theme: button.dataset.theme }); this._onSelect(button.dataset.style);
// A theme switch keeps the panel open, to flip back and forth comparing. this._togglePanel(false);
if (button.dataset.style) this._togglePanel(false);
}); });
}); });
@@ -157,17 +146,16 @@ class LayerToggleControl {
this._togglePanel(); this._togglePanel();
} }
setActive(source, theme) { setActive(name) {
this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => { this._panel.querySelectorAll(".basemap-panel__option").forEach((button) => {
const value = button.dataset.style ? source : theme; button.classList.toggle("active", button.dataset.style === name);
button.classList.toggle("active", (button.dataset.style ?? button.dataset.theme) === value);
}); });
} }
// Called once it's known there's no offline map to switch to (see the // Called once it's known there's no offline map to switch to (see the
// /api/offline-tiles check below) — an Online/Offline switch doesn't make // /api/offline-tiles check below) — an Online/Offline switch doesn't make
// sense to show at all when Offline was never going to work. The panel // sense to show at all when Offline was never going to work. The panel
// itself stays for the theme choice. // itself stays for its legend link.
hideSources() { hideSources() {
this._panel.querySelector(".basemap-panel__sources").hidden = true; this._panel.querySelector(".basemap-panel__sources").hidden = true;
} }
@@ -339,7 +327,7 @@ class RotationLockControl {
const map = new MaplibreMap({ const map = new MaplibreMap({
container: "map", container: "map",
style: onlineStyle(currentTheme), style: onlineStyle(),
center: CENTER, center: CENTER,
zoom: ZOOM, zoom: ZOOM,
// MapLibre's built-in Hash control: keeps #map=zoom/lat/lon in the URL in // MapLibre's built-in Hash control: keeps #map=zoom/lat/lon in the URL in
@@ -504,7 +492,7 @@ if (isLoggedIn()) new PluginsControl(map).mount(sidebar);
sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Offline hub"></div>`); sidebar.insertAdjacentHTML("beforeend", `<div class="sidebar-group-label" title="Offline hub"></div>`);
layerToggle.mount(sidebar); layerToggle.mount(sidebar);
layerToggle.setActive(currentSource, currentTheme); layerToggle.setActive("online");
new RoutePanelControl(map, gnssControl, profilePanel).mount(sidebar); new RoutePanelControl(map, gnssControl, profilePanel).mount(sidebar);
new OfflineDataControl().mount(sidebar); new OfflineDataControl().mount(sidebar);
@@ -522,18 +510,9 @@ setupSidePanelModes();
const mapLayersButton = new MapLayersButton(layerToggle); const mapLayersButton = new MapLayersButton(layerToggle);
map.addControl(mapLayersButton, "top-left"); map.addControl(mapLayersButton, "top-left");
function applyStyle({ source = currentSource, theme = currentTheme } = {}) { function applyStyle(name) {
if (theme !== currentTheme) { layerToggle.setActive(name);
try { map.setStyle(name === "offline" ? offlineStyle() : onlineStyle());
localStorage.setItem("mapTheme", theme);
} catch {
// private window / blocked storage: the choice just isn't remembered
}
}
currentSource = source;
currentTheme = theme;
layerToggle.setActive(source, theme);
map.setStyle(source === "offline" ? offlineStyle(theme) : onlineStyle(theme));
} }
// If a local PMTiles file is present, prefer it as the default style — its // If a local PMTiles file is present, prefer it as the default style — its
@@ -546,7 +525,7 @@ fetch("/api/offline-tiles")
.then((response) => response.json()) .then((response) => response.json())
.then(({ available }) => { .then(({ available }) => {
if (available) { if (available) {
applyStyle({ source: "offline" }); applyStyle("offline");
} else { } else {
layerToggle.hideSources(); layerToggle.hideSources();
} }
+14 -127
View File
@@ -1,129 +1,18 @@
// The base map's two color themes (Base map panel → Theme), applied to the // The base map's look: OpenFreeMap Liberty recolored after the National Park
// Liberty style JSON: map.js styles the map with them, /symbols.html draws // Service's Park Tiles "Standard" style. Colors sampled from the Park Tiles
// its legend from the same patched style, so the two can't drift apart. // legend swatches (nps.gov/maps/web/img/legend/*-standard.png) and their
// public Imagery style JSON (docs/nps-resources.adoc) — only the colors,
// none of their data or tiles. Line widths stay Liberty's own. Applied
// identically to the online style and the offline one (offline.pmtiles is
// built with Planetiler's OpenMapTiles profile, the schema Liberty expects).
// map.js styles the map with it and /symbols.html draws its legend from the
// same patched style, so the two can't drift apart.
// Recolors OpenFreeMap Liberty to a warm, NPS-Park-Tiles-inspired palette — export function patchOnlineStyle(style) {
// cream ground, muted roads/boundaries — mapped onto Liberty's OpenMapTiles return insertTrackOnlyLayer(parkTilesStyle(style));
// layer ids. Applied identically regardless of which PMTiles data actually
// backs the "openmaptiles" source (see offlineStyle() below): offline tiles
// are built by Planetiler's own OpenMapTiles profile (docs/development.adoc),
// the same schema Liberty already expects, so one patch serves both —
// no separate offline theme/palette to keep in sync. Only the layers that
// dominate the map's overall color read are touched; labels, halos, rail,
// and minor overlays (cemetery/hospital/school/pitch/track shading,
// building outlines) are left at Liberty's own defaults.
//
// wood/grass are deliberately left unpatched — Liberty's own green (a
// translucent landcover_wood/landcover_grass wash) already reads well over
// the patched cream background.
export const ONLINE_STYLE_PATCH = {
background: { "background-color": "#f9f6ef" },
// Liberty washes every built-up area in a translucent gray-tan below
// z12 (landuse_residential, maxzoom 12 — gone by this app's default
// z13) that the offline schema has no equivalent of; protomaps just
// leaves that ground as plain background/earth. Matched to background
// here rather than left alone, so a zoomed-out view doesn't read as
// visibly dingier online than offline.
landuse_residential: { "fill-color": "#f9f6ef" },
landcover_sand: { "fill-color": "#f0e4c4" },
water: { "fill-color": "#a3cedf" },
// fill-outline-color isn't touched by a plain fill-color patch — Liberty
// draws it separately, defaulting to a bright green that reads as a
// distinct border around named conservation areas (e.g. the Malé
// Karpaty CHKO). Matched to the fill itself, and park_outline's own
// dashed line hidden below, so a reserve blends in as ordinary forest —
// offline has no equivalent stroke at all (see park_a/park_b below),
// and the point was never to call reserves out as visibly different,
// on either side.
park: { "fill-color": "#b3e378", "fill-outline-color": "#b3e378" },
park_outline: { "line-opacity": 0 },
// fill-opacity: 0.5 matches the offline theme's own "buildings" layer —
// without it, Liberty's dense individual building footprints (each with
// its own outline) paint fully opaque and read much heavier/grayer than
// offline's softer, half-transparent fill over the same cream ground.
building: { "fill-color": "#ded7cc", "fill-opacity": 0.5 },
boundary_2: { "line-color": "#546619" },
boundary_3: { "line-color": "#546619" },
// Highway (motorway/trunk/primary), major (secondary/tertiary/link),
// minor (residential/service/track), pedestrian — each repeated for its
// tunnel_/bridge_ counterpart so a road doesn't change color when it
// dips into a tunnel or crosses a bridge. Rail is left alone.
//
// line-width below is a flat number, not Liberty's own zoom-interpolated
// expression — picked to match the offline theme's actual rendered width
// at this app's default zoom (13; verified live via queryRenderedFeatures
// on both sides), since without it Liberty's own curve draws surface
// roads roughly twice as thick as offline at street level, reading as a
// much bolder road network online.
// ponytail: tuned for z13 only, not a matching curve across all zooms —
// will drift back apart at very different zoom levels. Upgrade path:
// sample offline's width at a few more zooms and replace with a matching
// ["interpolate", ["linear"], ["zoom"], ...] expression.
road_motorway: { "line-color": "#fdefbe", "line-width": 2.26 },
road_trunk_primary: { "line-color": "#fdefbe", "line-width": 2.26 },
road_secondary_tertiary: { "line-color": "#fef7dd", "line-width": 1.87 },
road_link: { "line-color": "#fef7dd", "line-width": 1 },
road_motorway_link: { "line-color": "#fef7dd", "line-width": 1 },
road_minor: { "line-color": "#fffdf8" },
road_service_track: { "line-color": "#fffdf8" },
road_path_pedestrian: { "line-color": "#e9e2d8" },
road_motorway_casing: { "line-color": "#c9a66b", "line-width": 1.48 },
road_trunk_primary_casing: { "line-color": "#c9a66b", "line-width": 1.48 },
road_secondary_tertiary_casing: { "line-color": "#c9a66b", "line-width": 1 },
road_link_casing: { "line-color": "#c9a66b", "line-width": 1.5 },
road_motorway_link_casing: { "line-color": "#c9a66b", "line-width": 1.5 },
road_minor_casing: { "line-color": "#c9a66b" },
road_service_track_casing: { "line-color": "#c9a66b" },
tunnel_motorway: { "line-color": "#fdefbe" },
tunnel_trunk_primary: { "line-color": "#fdefbe" },
tunnel_secondary_tertiary: { "line-color": "#fef7dd" },
tunnel_link: { "line-color": "#fef7dd" },
tunnel_motorway_link: { "line-color": "#fef7dd" },
tunnel_minor: { "line-color": "#fffdf8" },
tunnel_service_track: { "line-color": "#fffdf8" },
tunnel_path_pedestrian: { "line-color": "#e9e2d8" },
tunnel_motorway_casing: { "line-color": "#c9a66b" },
tunnel_trunk_primary_casing: { "line-color": "#c9a66b" },
tunnel_secondary_tertiary_casing: { "line-color": "#c9a66b" },
tunnel_link_casing: { "line-color": "#c9a66b" },
tunnel_motorway_link_casing: { "line-color": "#c9a66b" },
tunnel_street_casing: { "line-color": "#c9a66b" },
bridge_motorway: { "line-color": "#fdefbe" },
bridge_trunk_primary: { "line-color": "#fdefbe" },
bridge_secondary_tertiary: { "line-color": "#fef7dd" },
bridge_link: { "line-color": "#fef7dd" },
bridge_motorway_link: { "line-color": "#fef7dd" },
bridge_street: { "line-color": "#fffdf8" },
bridge_service_track: { "line-color": "#fffdf8" },
bridge_path_pedestrian: { "line-color": "#e9e2d8" },
bridge_motorway_casing: { "line-color": "#c9a66b" },
bridge_trunk_primary_casing: { "line-color": "#c9a66b" },
bridge_secondary_tertiary_casing: { "line-color": "#c9a66b" },
bridge_link_casing: { "line-color": "#c9a66b" },
bridge_motorway_link_casing: { "line-color": "#c9a66b" },
bridge_street_casing: { "line-color": "#c9a66b" },
bridge_path_pedestrian_casing: { "line-color": "#c9a66b" },
};
export function patchOnlineStyle(style, theme = "maptool") {
if (theme === "parktiles") return insertTrackOnlyLayer(parkTilesStyle(style));
for (const layer of style.layers) {
const patch = ONLINE_STYLE_PATCH[layer.id];
if (patch) Object.assign((layer.paint ??= {}), patch);
}
return insertTrackOnlyLayer(style);
} }
// The alternative "NPS Park Tiles" theme (Base map panel → Theme), a closer const PARK_TILES_PATCH = {
// take on Park Tiles' Standard style than ONLINE_STYLE_PATCH's: colors
// sampled from the Park Tiles legend swatches
// (nps.gov/maps/web/img/legend/*-standard.png) and the public Imagery style
// JSON (docs/nps-resources.adoc) — only the colors, none of their data.
// Line widths stay Liberty's own.
export const PARK_TILES_PATCH = {
background: { "background-color": "#f7eee8" }, background: { "background-color": "#f7eee8" },
natural_earth: { "raster-opacity": 0 }, natural_earth: { "raster-opacity": 0 },
landuse_residential: { "fill-color": "#f7eee8" }, landuse_residential: { "fill-color": "#f7eee8" },
@@ -135,8 +24,7 @@ export const PARK_TILES_PATCH = {
water: { "fill-color": "#b5d0de" }, water: { "fill-color": "#b5d0de" },
waterway_river: { "line-color": "#b5d0de" }, waterway_river: { "line-color": "#b5d0de" },
waterway_other: { "line-color": "#b5d0de" }, waterway_other: { "line-color": "#b5d0de" },
// Park Tiles' area fill is this muted sage; #b3e378 (ONLINE_STYLE_PATCH) // Park Tiles' area fill is this muted sage (#b3e378 is their park *point* color).
// is their park *point* color.
park: { "fill-color": "#ced2b7", "fill-opacity": 1, "fill-outline-color": "#ced2b7" }, park: { "fill-color": "#ced2b7", "fill-opacity": 1, "fill-outline-color": "#ced2b7" },
park_outline: { "line-color": "#8ba35a", "line-width": 1.3, "line-opacity": 1 }, park_outline: { "line-color": "#8ba35a", "line-width": 1.3, "line-opacity": 1 },
building: { "fill-color": "#e7e4d5", "fill-outline-color": "#b8b1a0" }, building: { "fill-color": "#e7e4d5", "fill-outline-color": "#b8b1a0" },
@@ -206,8 +94,7 @@ function parkTilesStyle(style) {
// "track"` separately from `"service"` (see the filter below), so rather // "track"` separately from `"service"` (see the filter below), so rather
// than recoloring the merged layer (which would mislabel paved driveways // than recoloring the merged layer (which would mislabel paved driveways
// as unpaved), this clones it into a second layer scoped to `class == // as unpaved), this clones it into a second layer scoped to `class ==
// "track"` only, dashed and dirt-brown — matching how the offline theme // "track"` only, dashed and dirt-brown.
// already renders protomaps' own separate "other"/"path" road kind.
// Surface-level only (excludes tunnel_/bridge_ variants): an unpaved track // Surface-level only (excludes tunnel_/bridge_ variants): an unpaved track
// in a tunnel or on a bridge is rare enough not to be worth a third layer. // in a tunnel or on a bridge is rare enough not to be worth a third layer.
function insertTrackOnlyLayer(style) { function insertTrackOnlyLayer(style) {
+4 -5
View File
@@ -31,9 +31,9 @@
<body> <body>
<section class="legend"> <section class="legend">
<h2>Map legend</h2> <h2>Map legend</h2>
<p>How the base map draws each feature in its two themes (Base map panel → Theme), read from the actual patched style.</p> <p>How the base map (colors after the NPS Park Tiles style) draws each feature, read from the actual patched style.</p>
<table> <table>
<thead><tr><th>Feature</th><th>Maptool</th><th>NPS Park Tiles</th></tr></thead> <thead><tr><th>Feature</th><th>Look</th></tr></thead>
<tbody></tbody> <tbody></tbody>
</table> </table>
</section> </section>
@@ -127,10 +127,9 @@
} }
const template = await fetch("/vendor/liberty-style/liberty.json").then((response) => response.json()); const template = await fetch("/vendor/liberty-style/liberty.json").then((response) => response.json());
const themes = ["maptool", "parktiles"].map((theme) => const layers = Object.fromEntries(patchOnlineStyle(template).layers.map((l) => [l.id, l]));
Object.fromEntries(patchOnlineStyle(structuredClone(template), theme).layers.map((l) => [l.id, l])));
document.querySelector(".legend tbody").innerHTML = ROWS.map(([label, id, casingId]) => document.querySelector(".legend tbody").innerHTML = ROWS.map(([label, id, casingId]) =>
`<tr><td>${label} <code>${id}</code></td>${themes.map((layers) => swatch(layers, id, casingId)).join("")}</tr>`).join(""); `<tr><td>${label} <code>${id}</code></td>${swatch(layers, id, casingId)}</tr>`).join("");
</script> </script>
</body> </body>
</html> </html>
-9
View File
@@ -53,15 +53,6 @@
</button> </button>
</div> </div>
<div class="basemap-panel__list"> <div class="basemap-panel__list">
<div class="basemap-panel__heading">Theme</div>
<button type="button" class="basemap-panel__option" data-theme="maptool">
<span>Maptool</span>
<span class="basemap-panel__check">&check;</span>
</button>
<button type="button" class="basemap-panel__option" data-theme="parktiles">
<span>NPS Park Tiles</span>
<span class="basemap-panel__check">&check;</span>
</button>
<a class="basemap-panel__link" href="/symbols.html" target="_blank">Legend &amp; symbols ↗</a> <a class="basemap-panel__link" href="/symbols.html" target="_blank">Legend &amp; symbols ↗</a>
</div> </div>
</div> </div>