From 085c14beca259e9254e6e27bf81e001cfe85f60e Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Wed, 18 Nov 2026 23:01:13 +0100 Subject: [PATCH] All 307 NPS symbols (symbol-library 2024 revision, CC0) vendored by bin/nps-symbols-sync.mjs and browsable at /symbols.html; POI_ICONS maps every symbol by name plus the OsmAnd names, the note icon picker gets a filter, and only the glyphs a shown file uses get rasterized --- bin/nps-symbols-sync.mjs | 48 ++++ docs/architecture.adoc | 19 +- docs/nps-resources.adoc | 32 +-- docs/third-party-notices.adoc | 5 +- public/css/style.css | 10 +- public/js/gpx.js | 22 +- public/js/icons.js | 287 +++++--------------- public/js/notes.js | 44 ++- public/symbols.html | 53 ++++ public/vendor/nps-symbols/nps-symbols.mjs | 310 ++++++++++++++++++++++ 10 files changed, 551 insertions(+), 279 deletions(-) create mode 100644 bin/nps-symbols-sync.mjs create mode 100644 public/symbols.html create mode 100644 public/vendor/nps-symbols/nps-symbols.mjs diff --git a/bin/nps-symbols-sync.mjs b/bin/nps-symbols-sync.mjs new file mode 100644 index 0000000..9efb729 --- /dev/null +++ b/bin/nps-symbols-sync.mjs @@ -0,0 +1,48 @@ +#!/usr/bin/env node +// Vendors every NPS map symbol (22 px, black, standalone) from +// nationalparkservice/symbol-library's jakecoolidge-revision-2024 branch +// (PR #226, the newest artwork: a superset of npmap5-plugins' copy) into +// one ES module, { name: "" }, cleaned to a bare viewBox and +// fill="currentColor". Public domain (CC0). Pinned to a commit; to update, +// change REF and run `node bin/nps-symbols-sync.mjs`. +import { mkdirSync, writeFileSync } from "node:fs"; + +const REPO = "nationalparkservice/symbol-library"; +const REF = "94f772a21b593f2cdb6d2a2b8a5cc4d3dc5e3a61"; +const out = new URL("../public/vendor/nps-symbols/", import.meta.url).pathname; + +const tree = await (await fetch(`https://api.github.com/repos/${REPO}/git/trees/${REF}?recursive=1`)).json(); +const files = tree.tree.map((t) => t.path).filter((p) => /^src\/standalone\/.+-black-22\.svg$/.test(p) && !p.includes("transparent")); + +const clean = (svg) => + svg + .replace(/<\?xml[^>]*>||<(style|title)[\s\S]*?<\/\1>/g, "") + .replace(/<\w+[^>]*fill="none"[^>]*\/>/g, "") // invisible leftovers + .replace(/\s(id|fill|class|style|enable-background|xml:space)="[^"]*"/g, "") + .replace(/]*>/, '') + .replace(/\s+/g, " ") + .replace(/> <") + .trim(); + +const symbols = {}; +for (let i = 0; i < files.length; i += 6) { + await Promise.all( + files.slice(i, i + 6).map(async (path) => { + const res = await fetch(`https://raw.githubusercontent.com/${REPO}/${REF}/${path}`); + if (!res.ok) throw new Error(`${path}: ${res.status}`); + symbols[path.match(/([^/]+)-black-22\.svg$/)[1]] = clean(await res.text()); + }), + ); +} + +mkdirSync(out, { recursive: true }); +writeFileSync( + `${out}nps-symbols.mjs`, + `// Generated by bin/nps-symbols-sync.mjs from ${REPO}@${REF.slice(0, 7)} (CC0).\nexport const NPS_SYMBOLS = {\n` + + Object.keys(symbols) + .sort() + .map((name) => ` ${JSON.stringify(name)}: ${JSON.stringify(symbols[name])},\n`) + .join("") + + "};\n", +); +console.log(`${Object.keys(symbols).length} symbols`); diff --git a/docs/architecture.adoc b/docs/architecture.adoc index 0c61c0d..b0dd17f 100644 --- a/docs/architecture.adoc +++ b/docs/architecture.adoc @@ -477,20 +477,17 @@ reaches a layer, rather than a `coalesce` in a style expression — see below for why. Unlike a pin, which has to anchor at its tip, the badge is centered directly on the coordinate with plain default anchoring, which also means the category-glyph layer on top needs no offset math: -both layers just share the same center anchor at `[0, 0]`. A small -curated icon set (`public/js/icons.js`'s `POI_ICONS`, covering the -categories p4n2gpx actually uses, not an exhaustive OsmAnd icon set) +both layers just share the same center anchor at `[0, 0]`. The icon set +(`public/js/icons.js`'s `POI_ICONS`: every NPS symbol by its own name, +plus the OsmAnd names p4n2gpx/Overpass POIs use mapped onto them) draws a white glyph on top of the badge for any waypoint whose `icon` matches a known key (filtered out entirely for anything else, so an unrecognized icon key just falls back to a plain colored badge rather -than a broken/missing image warning). All seven glyphs are the National -Park Service's own map symbols — pulled from -`github.com/nationalparkservice/npmap5-plugins`'s bundled -`symbol-library` (CC0-licensed, an actively-maintained monorepo that's -the designated replacement for the same org's older standalone -`symbol-library` repo, per its maintainer) — a professional, -purpose-built icon set beats hand-drawing "fuel pump"/"picnic table" -glyphs from scratch. +than a broken/missing image warning). The glyphs are the National +Park Service's own map symbols, all of them, vendored by +`bin/nps-symbols-sync.mjs` (CC0, see `docs/nps-resources.adoc`) and +browsable at `/symbols.html`. Only the ones a shown file uses get +rasterized. + Both the badge and the glyphs are rasterized from their source SVGs (an `` → `` → `ImageData` round trip, since `map.addImage` diff --git a/docs/nps-resources.adoc b/docs/nps-resources.adoc index 1ef9537..31b825e 100644 --- a/docs/nps-resources.adoc +++ b/docs/nps-resources.adoc @@ -15,8 +15,10 @@ checking here before searching from zero next time. |=== | What | Where | License -| `symbol-library` (map category icons, POI badge glyphs) -| `public/js/icons.js`'s `POI_ICONS`/`PARK4NIGHT_TAGS` +| `symbol-library` (map category icons, POI badge glyphs): all 307 + symbols, browsable with search at `/symbols.html` +| `public/vendor/nps-symbols/` (from `bin/nps-symbols-sync.mjs`), used by + `public/js/icons.js`'s `POI_ICONS`/`PARK4NIGHT_TAGS` | CC0 (public domain) | `home-button` (the "Home" map control) @@ -126,23 +128,21 @@ NPS-flavored. no current use case. |=== -=== Pending upstream: symbol artwork revisions +=== Symbol artwork: the 2024 revision branch https://github.com/nationalparkservice/symbol-library/pull/226 ("npmap-hfc -standardization 2024") — a large (169-file), still-*open*/unmerged artwork -revision pass on the *old* standalone repo, open since January 2024. Of the -icons this app actually uses, three have revised artwork proposed there: +standardization 2024", branch `jakecoolidge-revision-2024`) is the newest +artwork (May 2024), newer than npmap5-plugins' copy (December 2023) and a +superset of it: 307 standalone symbols vs. 305, adding `wifi`, `toilet`, +`e-bike`, `diesel`, `stargazing`, `snowshoeing`, `food-storage`, … and +renaming a few (`motor-bike-trail` → `motorbike-trail`). The PR is still +open, but it is where the artwork lives now, so `bin/nps-symbols-sync.mjs` +vendors every `src/standalone/*-black-22.svg` from a pinned commit of that +branch. To update: change `REF` there and run it. -* `bicycle-trail` (our `sport_cycling`/`vtt`) -* `campground` (our `tourism_camp_site`) -* `pets-on-leash` (our `animaux`) - -Plus filename-only renames (e.g. `motor-bike-trail` → `motorbike-trail`, -`sea-plane` → `seaplane`) and a handful of new icons not relevant to our -current `PARK4NIGHT_TAGS` mapping (`e-bike`, `foraging-gathering`, -`seaplane`, `toilet`, `windmill`). Deliberately *not* pulled in — it's an -unmerged draft, could still change. Worth revisiting once it lands on -`main` in whichever repo ends up canonical. +Locus Map's "NPS Map Symbols" packs (https://dfgtec.com/map-nps-symbols) +are ~250 of the same NPS symbols as PNGs under CC BY-NC-SA; the CC0 SVG +source above is both larger and freer. [[park-tiles]] == Park Tiles (the NPS basemap theme) diff --git a/docs/third-party-notices.adoc b/docs/third-party-notices.adoc index 6b86dcc..8050849 100644 --- a/docs/third-party-notices.adoc +++ b/docs/third-party-notices.adoc @@ -71,7 +71,10 @@ included alongside): the Material Design Icons (`@mdi/js`, version in `public/js/icons.js` uses for the app's own UI icons. Only the icons actually used are vendored, as `mdi.mjs`, generated by `bin/vendor-sync.mjs`. The point and park4night glyphs stay the -National Park Service's (below). +National Park Service's: `public/vendor/nps-symbols/`, CC0, generated by +`bin/nps-symbols-sync.mjs` from +https://github.com/nationalparkservice/symbol-library (branch +`jakecoolidge-revision-2024`). Also vendored under `public/vendor/` — MIT-licensed (© 2013 Panayiotis Lipiridis), attribution required (this notice satisfies that): diff --git a/public/css/style.css b/public/css/style.css index 1c42858..d50f9bf 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1634,11 +1634,19 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr grid-template-columns: repeat(6, 1fr); gap: 2px; margin: 2px 0; + max-height: 140px; /* ~330 icons: a scrolling grid, narrowed by the filter above */ + overflow-y: auto; +} + +.notes-panel__icon-filter { + width: 100%; + box-sizing: border-box; } /* Same "author display wins over the UA [hidden] rule" gotcha as .gpx-panel__action[hidden] elsewhere in this file. */ -.notes-panel__icons[hidden] { +.notes-panel__icon-picker[hidden], +.notes-panel__icon-option[hidden] { display: none; } diff --git a/public/js/gpx.js b/public/js/gpx.js index 02a2275..36ea094 100644 --- a/public/js/gpx.js +++ b/public/js/gpx.js @@ -53,16 +53,9 @@ export class GpxPanelControl { this._openDownloadMenu = null; // the one gpx-tree__download-menu currently open, if any // setStyle() (switching the Online/Offline base map) tears down all - // custom sources/layers/images — re-register the category glyphs before - // putting visible GPX layers back, so a symbol layer added right away - // doesn't reference a not-yet-existing image. Badge images are handled - // separately (_registerBadgeColors, called from _addLayers) since which - // colors are needed depends on which file/category is being shown. - this._iconsReady = this._registerCategoryGlyphs(); - map.on("style.load", () => { - this._iconsReady = this._registerCategoryGlyphs(); - this._visible.forEach((path) => this._addLayers(path)); - }); + // custom sources/layers/images — _addLayers re-registers the glyph and + // badge images a file needs before putting its layers back. + map.on("style.load", () => this._visible.forEach((path) => this._addLayers(path))); // notes.js writes directly into the same GPX store (a hand-drawn note // saved into a .geojson layer) — refresh so a newly created/grown file @@ -79,7 +72,7 @@ export class GpxPanelControl { }); } - // Registered once, always white, as plain (non-SDF) images: these used to + // Registered on first use, always white, as plain (non-SDF) images: these used to // be SDF images tinted white via icon-color, but MapLibre's SDF rendering // assumes the source encodes an actual distance field (a smooth multi-pixel // gradient at each edge) — feeding it a normally-antialiased raster (a @@ -89,9 +82,10 @@ export class GpxPanelControl { // below), there's no need for SDF's runtime-tintable alpha mask at all — // baking the color into the raster and skipping SDF renders as sharp as // any ordinary sprite. - async _registerCategoryGlyphs() { + // Only the icons a file actually uses: there are ~330 to choose from. + async _registerCategoryGlyphs(keys) { await Promise.all( - POI_ICON_KEYS.map(async (key) => { + [...keys].filter((key) => POI_ICONS[key]).map(async (key) => { if (this._map.hasImage(key)) return; const whiteSvg = POI_ICONS[key].replace(/currentColor/g, "#fff"); const imageData = await svgToImageData(whiteSvg, POI_ICON_IMAGE_SIZE); @@ -749,7 +743,7 @@ export class GpxPanelControl { // enough to cluster (a handful of waypoints just render individually). this._map.addSource(pointsId, { type: "geojson", data: points, cluster: true, clusterRadius: 50, clusterMaxZoom: 14 }); const badgeColors = new Set(points.features.map((f) => f.properties.color)); - await Promise.all([this._iconsReady, this._registerBadgeColors(badgeColors)]); + await Promise.all([this._registerCategoryGlyphs(new Set(points.features.map((f) => f.properties.icon))), this._registerBadgeColors(badgeColors)]); if (!this._map.getSource(pointsId)) return true; // a style.load (basemap switch) tore it down while icons were loading this._addClusterLayers(pointsId, path); diff --git a/public/js/icons.js b/public/js/icons.js index e099b05..6144d7e 100644 --- a/public/js/icons.js +++ b/public/js/icons.js @@ -34,6 +34,7 @@ import { mdiWeatherSunsetUp, mdiWikipedia, } from "/vendor/mdi/mdi.mjs"; +import { NPS_SYMBOLS } from "/vendor/nps-symbols/nps-symbols.mjs"; const mdi = (path) => ``; @@ -81,184 +82,46 @@ export const TRACK_ICON = GPX_ICON; export const MAP_MARKER_ICON = ` `; -// POI category glyphs (park4night/OsmAnd exports), keyed by the OsmAnd icon -// name a file's extension carries — a small curated set for -// the categories park4night actually uses (see waypoint_style in -// lib/maptool/gpx.rb), not an exhaustive OsmAnd icon set. -// -// These are the National Park Service's own map pictograms, not -// hand-drawn — a professional, widely-recognized icon set built for -// exactly this job (small monochrome map markers) beats reinventing "fuel -// pump"/"picnic table" glyphs from scratch. Pulled from -// github.com/nationalparkservice/npmap5-plugins's bundled `symbol-library` -// (src/-22.svg) — an actively-maintained monorepo that's the -// designated replacement for the same org's older standalone -// `symbol-library` repo (confirmed by its maintainer: -// github.com/nationalparkservice/npmap5-plugins/issues/4), with a much -// larger icon vocabulary. CC0-licensed (public domain) — no attribution -// required. -// -// All filled shapes — these render at ~14px on the map, where a hairline -// stroke disappears — and rasterized (non-SDF; a plain colored raster, not -// tinted at render time, see gpx.js's _registerCategoryGlyphs) so only the -// alpha shape matters, not the actual `currentColor` value. - -// src/wilderness-22.svg — exported (unlike BICYCLE_TRAIL_ICON below, this -// one's also used outside this file) as the Overlays panel's Terrain -// shading glyph (overlays.js): the closest honest match in NPS's set for -// "mountains/terrain" — it has no weather or elevation-specific pictogram. -export const WILDERNESS_ICON = ` -`; - -// src/bicycle-trail-22.svg — pulled out to its own constant since it's also -// used unrasterized, inline, as PARK4NIGHT_TAGS.vtt below. -const BICYCLE_TRAIL_ICON = ` - - - - - -`; - -// src/store-22.svg — NPS's generic shop pictogram, the closest match in -// their set for both a supermarket and a convenience store (no separate -// grocery-specific glyph exists there). -const STORE_ICON = ` - - - - - -`; +// The National Park Service's map pictograms for points: every symbol of +// their symbol-library, vendored by bin/nps-symbols-sync.mjs (CC0, 22 px, +// filled shapes — they render at ~14px on the map, where a hairline stroke +// disappears). Rasterized for the map (non-SDF, see gpx.js's +// _registerCategoryGlyphs), so only the alpha shape matters there. +export { NPS_SYMBOLS }; +const nps = (name) => NPS_SYMBOLS[name]; +export const WILDERNESS_ICON = nps("wilderness"); // also the Overlays panel's Terrain shading glyph +export const WALKING_ICON = nps("walking"); // also the Overlays panel's Hiking trails glyph +// A point's `icon` property names its glyph: any NPS symbol name +// ("drinking-water", "campground", …), or one of these OsmAnd icon names a +// park4night/OsmAnd export (lib/maptool/gpx.rb's waypoint_style) and the +// Overpass POIs (lib/maptool/overpass_pois.rb) carry. These come first in +// the note icon picker. export const POI_ICONS = { - // src/parking-22.svg - amenity_parking: ` -`, - - // src/campground-22.svg - tourism_camp_site: ` - - - - -`, - - // src/picnic-area-22.svg - leisure_picnic_table: ` -`, - - // src/gas-station-22.svg - amenity_fuel: ` -`, - - // src/lodging-22.svg - tourism_hotel: ` - - - - -`, - - // src/wilderness-22.svg + amenity_parking: nps("parking"), + tourism_camp_site: nps("campground"), + leisure_picnic_table: nps("picnic-area"), + amenity_fuel: nps("gas-station"), + tourism_hotel: nps("lodging"), forest: WILDERNESS_ICON, - - // src/bicycle-trail-22.svg - sport_cycling: BICYCLE_TRAIL_ICON, + sport_cycling: nps("bicycle-trail"), + amenity_drinking_water: nps("drinking-water"), + amenity_sanitary_dump_station: nps("sanitary-disposal-station"), + amenity_toilets: nps("restrooms"), + shop_gas: nps("propane"), + amenity_electricity: nps("electrical-hookup"), + shop_laundry: nps("laundry"), + leisure_playground: nps("playground"), + tourism_viewpoint: nps("scenic-viewpoint"), + leisure_swimming: nps("swimming"), + leisure_fishing: nps("fishing"), + sport_climbing: nps("climbing"), + route_hiking: WALKING_ICON, + shop_supermarket: nps("store"), + shop_convenience: nps("store"), + ...NPS_SYMBOLS, }; -// National Park Service map symbols (same source/license as POI_ICONS above) -// used as small inline glyphs next to a park4night waypoint's Services/ -// Activities tags (see PARK4NIGHT_TAGS and formatDescription in -// public/js/gpx.js) — pulled into named constants first since a few codes -// share the same real-world facility (eau_noire/eau_usee are both a dump -// station, gaz/gpl are both a propane refill, peche/peche_pied are both -// fishing) and BICYCLE_TRAIL_ICON is also POI_ICONS.sport_cycling above. -const PETS_ON_LEASH_ICON = ` -`; - -const SHOWERS_ICON = ` -`; - -const SANITARY_DISPOSAL_ICON = ` -`; - -const ELECTRICAL_HOOKUP_ICON = ` -`; - -const PROPANE_ICON = ` -`; - -const LAUNDRY_ICON = ` -`; - -const SWIMMING_ICON = ` -`; - -const DRINKING_WATER_ICON = ` -`; - -const TRASH_DUMPSTER_ICON = ` -`; - -const RESTROOMS_ICON = ` -`; - -const RIVER_RAFTING_ICON = ` -`; - -const CLIMBING_ICON = ` -`; - -const PLAYGROUND_ICON = ` -`; - -const MOTOR_BIKE_TRAIL_ICON = ` -`; - -const FISHING_ICON = ` -`; - -const SCENIC_VIEWPOINT_ICON = ` -`; - -// Exported (unlike the other POI glyphs around it) — also used as the -// Overlays panel's Hiking trails glyph (hiking_trails.js), same "reuse an -// existing NPS-sourced pictogram" story as WILDERNESS_ICON above rather -// than hand-drawing another one. -export const WALKING_ICON = ` -`; - -const GUIDED_TOURS_ICON = ` -`; - -const WIND_SURFING_ICON = ` -`; - -// These three have no equivalent in the older standalone symbol-library -// repo (see POI_ICONS above) — pulled from npmap5-plugins' bundled, -// actively-maintained symbol-library instead (CC0-licensed), which has a -// much larger vocabulary. -const WIFI_ICON = ` -`; - -const CELLULAR_SIGNAL_ICON = ` -`; - -const WINTER_RECREATION_AREA_ICON = ` -`; - // park4night's fixed vocabulary of Services/Activities codes (the ones // p4n2gpx exports actually use — not necessarily park4night's entire API), // each with a human label (always shown) and an icon where the NPS set has @@ -267,61 +130,35 @@ const WINTER_RECREATION_AREA_ICON = ` // existed, so nothing p4n2gpx might add later is ever hidden. export const PARK4NIGHT_TAGS = { // Services - animaux: { icon: PETS_ON_LEASH_ICON, label: "Pets allowed" }, + animaux: { icon: nps("pets-on-leash"), label: "Pets allowed" }, boulangerie: { label: "Bakery nearby" }, - caravaneige: { icon: WINTER_RECREATION_AREA_ICON, label: "Winter/snow camping" }, - donnees_mobile: { icon: CELLULAR_SIGNAL_ICON, label: "Mobile data coverage" }, - douche: { icon: SHOWERS_ICON, label: "Showers" }, - eau_noire: { icon: SANITARY_DISPOSAL_ICON, label: "Black water disposal" }, - eau_usee: { icon: SANITARY_DISPOSAL_ICON, label: "Grey water disposal" }, - electricite: { icon: ELECTRICAL_HOOKUP_ICON, label: "Electricity" }, - gaz: { icon: PROPANE_ICON, label: "Gas/propane refill" }, - gpl: { icon: PROPANE_ICON, label: "LPG refill" }, + caravaneige: { icon: nps("winter-recreation-area"), label: "Winter/snow camping" }, + donnees_mobile: { icon: nps("cellular-signal"), label: "Mobile data coverage" }, + douche: { icon: nps("showers"), label: "Showers" }, + eau_noire: { icon: nps("sanitary-disposal-station"), label: "Black water disposal" }, + eau_usee: { icon: nps("sanitary-disposal-station"), label: "Grey water disposal" }, + electricite: { icon: nps("electrical-hookup"), label: "Electricity" }, + gaz: { icon: nps("propane"), label: "Gas/propane refill" }, + gpl: { icon: nps("propane"), label: "LPG refill" }, lavage: { label: "Vehicle wash" }, - laverie: { icon: LAUNDRY_ICON, label: "Laundry" }, - piscine: { icon: SWIMMING_ICON, label: "Swimming pool" }, - point_eau: { icon: DRINKING_WATER_ICON, label: "Drinking water" }, - poubelle: { icon: TRASH_DUMPSTER_ICON, label: "Trash disposal" }, - wc_public: { icon: RESTROOMS_ICON, label: "Public toilet" }, - wifi: { icon: WIFI_ICON, label: "Wi-Fi" }, + laverie: { icon: nps("laundry"), label: "Laundry" }, + piscine: { icon: nps("swimming"), label: "Swimming pool" }, + point_eau: { icon: nps("drinking-water"), label: "Drinking water" }, + poubelle: { icon: nps("trash-dumpster"), label: "Trash disposal" }, + wc_public: { icon: nps("restrooms"), label: "Public toilet" }, + wifi: { icon: nps("wifi"), label: "Wi-Fi" }, // Activities - baignade: { icon: SWIMMING_ICON, label: "Swimming" }, - eaux_vives: { icon: RIVER_RAFTING_ICON, label: "Whitewater sports" }, - escalade: { icon: CLIMBING_ICON, label: "Climbing" }, - jeux_enfants: { icon: PLAYGROUND_ICON, label: "Playground" }, - moto: { icon: MOTOR_BIKE_TRAIL_ICON, label: "Motorcycling" }, - peche: { icon: FISHING_ICON, label: "Fishing" }, - peche_pied: { icon: FISHING_ICON, label: "Shore fishing" }, - point_de_vue: { icon: SCENIC_VIEWPOINT_ICON, label: "Scenic viewpoint" }, + baignade: { icon: nps("swimming"), label: "Swimming" }, + eaux_vives: { icon: nps("river-rafting"), label: "Whitewater sports" }, + escalade: { icon: nps("climbing"), label: "Climbing" }, + jeux_enfants: { icon: nps("playground"), label: "Playground" }, + moto: { icon: nps("motorbike-trail"), label: "Motorcycling" }, + peche: { icon: nps("fishing"), label: "Fishing" }, + peche_pied: { icon: nps("fishing"), label: "Shore fishing" }, + point_de_vue: { icon: nps("scenic-viewpoint"), label: "Scenic viewpoint" }, rando: { icon: WALKING_ICON, label: "Hiking" }, - visites: { icon: GUIDED_TOURS_ICON, label: "Sightseeing" }, - vtt: { icon: BICYCLE_TRAIL_ICON, label: "Mountain biking" }, - windsurf: { icon: WIND_SURFING_ICON, label: "Windsurfing" }, + visites: { icon: nps("guided-tours"), label: "Sightseeing" }, + vtt: { icon: nps("bicycle-trail"), label: "Mountain biking" }, + windsurf: { icon: nps("wind-surfing"), label: "Windsurfing" }, }; - -// Extends POI_ICONS (and so POI_ICON_KEYS, and what a marker badge can -// show — see gpx.js's _registerCategoryGlyphs) with a handful of the same -// symbols PARK4NIGHT_TAGS above already vendors, reused rather than -// duplicated — this app's own hand-drawn notes (notes.js's icon picker) -// need marker-badge glyphs for "water source"/"dump station"/"viewpoint" -// far more than the original OSM-POI-upload set (parking/hotel/fuel) ever -// covered. Object.assign, not more entries in the POI_ICONS literal -// itself, since these constants are declared below it in this file. -Object.assign(POI_ICONS, { - amenity_drinking_water: DRINKING_WATER_ICON, - amenity_sanitary_dump_station: SANITARY_DISPOSAL_ICON, - amenity_toilets: RESTROOMS_ICON, - shop_gas: PROPANE_ICON, - amenity_electricity: ELECTRICAL_HOOKUP_ICON, - shop_laundry: LAUNDRY_ICON, - leisure_playground: PLAYGROUND_ICON, - tourism_viewpoint: SCENIC_VIEWPOINT_ICON, - leisure_swimming: SWIMMING_ICON, - leisure_fishing: FISHING_ICON, - sport_climbing: CLIMBING_ICON, - route_hiking: WALKING_ICON, - shop_supermarket: STORE_ICON, - shop_convenience: STORE_ICON, -}); - diff --git a/public/js/notes.js b/public/js/notes.js index cc72c51..82635c8 100644 --- a/public/js/notes.js +++ b/public/js/notes.js @@ -1,5 +1,5 @@ import { Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs"; -import { NOTE_PIN_ICON, POI_ICONS } from "/js/icons.js"; +import { NOTE_PIN_ICON, NPS_SYMBOLS, POI_ICONS } from "/js/icons.js"; import { notifyGpxStoreChanged } from "/js/panels.js"; // Human labels for the icon picker's title attribute — POI_ICONS' own keys @@ -28,6 +28,16 @@ const ICON_LABELS = { shop_convenience: "Convenience store", }; +// The picker: the labelled everyday ones first, then every other NPS symbol +// (named after its file, "drinking-water" → "drinking water"). +const CURATED = Object.keys(ICON_LABELS); +const PICKER_ICONS = [ + ...CURATED.map((key) => [key, ICON_LABELS[key]]), + ...Object.keys(NPS_SYMBOLS) + .filter((name) => !CURATED.some((key) => POI_ICONS[key] === NPS_SYMBOLS[name])) + .map((name) => [name, name.replace(/-/g, " ")]), +]; + const NEW_FOLDER_VALUE = "__new__"; // Every hand-drawn note (from here or measure.js's "Save as note") gets one @@ -57,14 +67,15 @@ export class NoteSaveForm { this._el.hidden = true; this._el.innerHTML = ` -
- - ${Object.keys(POI_ICONS) - .map( - (key) => - ``, - ) - .join("")} +
+ +
+ + ${PICKER_ICONS.map( + ([key, label]) => + ``, + ).join("")} +
@@ -77,7 +88,14 @@ export class NoteSaveForm { container.appendChild(this._el); this._title = this._el.querySelector(".notes-panel__title"); - this._iconPicker = this._el.querySelector(".notes-panel__icons"); + this._iconPicker = this._el.querySelector(".notes-panel__icon-picker"); + this._iconFilter = this._el.querySelector(".notes-panel__icon-filter"); + this._iconFilter.addEventListener("input", () => { + const query = this._iconFilter.value.trim().toLowerCase(); + this._iconPicker.querySelectorAll(".notes-panel__icon-option").forEach((b) => { + b.hidden = query !== "" && !`${b.title} ${b.dataset.icon}`.toLowerCase().includes(query); + }); + }); this._body = this._el.querySelector(".notes-panel__body"); this._target = this._el.querySelector(".notes-panel__target"); this._newName = this._el.querySelector(".notes-panel__new-name"); @@ -109,7 +127,11 @@ export class NoteSaveForm { this._title.value = ""; this._body.value = ""; this._selectedIcon = ""; - this._iconPicker.querySelectorAll(".notes-panel__icon-option").forEach((b, i) => b.classList.toggle("active", i === 0)); + this._iconFilter.value = ""; + this._iconPicker.querySelectorAll(".notes-panel__icon-option").forEach((b, i) => { + b.classList.toggle("active", i === 0); + b.hidden = false; + }); this._onIconChange?.(this._selectedIcon); // An icon only makes sense on a single point — Measure's "Save as // note" can hand this a LineString/Polygon, which has no one spot for diff --git a/public/symbols.html b/public/symbols.html new file mode 100644 index 0000000..9876790 --- /dev/null +++ b/public/symbols.html @@ -0,0 +1,53 @@ + + + + + + MapTool symbols + + + + +
+

Point symbols

+

National Park Service map symbols (CC0) and the OsmAnd names mapped onto them. Click one to copy its name, the value of a point's icon property.

+ +
+
+ + + diff --git a/public/vendor/nps-symbols/nps-symbols.mjs b/public/vendor/nps-symbols/nps-symbols.mjs new file mode 100644 index 0000000..30cfb97 --- /dev/null +++ b/public/vendor/nps-symbols/nps-symbols.mjs @@ -0,0 +1,310 @@ +// Generated by bin/nps-symbols-sync.mjs from nationalparkservice/symbol-library@94f772a (CC0). +export const NPS_SYMBOLS = { + "aed": "", + "airboat": "", + "airfield": "", + "airport": "", + "alcohol": "", + "all-terrain-trail": "", + "amphitheater": "", + "aquatic-invasive-species-decontamination-station": "", + "aquatic-invasive-species-inspection-sticker": "", + "archery": "", + "art": "", + "ash-disposal": "", + "assistive-listening-systems": "", + "assistive-listening-systems-t-coil-compatible": "", + "atm": "", + "audio-description": "", + "audio-tour": "", + "automated-entrance": "", + "automobiles": "", + "baby-changing-station": "", + "backcountry-camping-permit": "", + "baseball": "", + "beach-access": "", + "bear-box": "", + "bear-canister": "", + "bear-spray": "", + "bear-spray-purchase": "", + "bear-spray-recycling": "", + "bear-spray-rental": "", + "bear-viewing": "", + "benches-seating": "", + "bicycle-trail": "", + "bike-rack": "", + "bike-rental": "", + "bike-repairs": "", + "birding-wildlife-viewing": "", + "boat-launch": "", + "boat-tour": "", + "boat-trailer-parking": "", + "boating": "", + "boating-permit": "", + "book-and-souvenir-shop": "", + "bookstore": "", + "bottle-filling-station": "", + "bottles": "", + "braille": "", + "breastfeeding-station": "", + "bridge": "", + "brochure": "", + "building": "", + "building-footprint": "", + "buoy": "", + "bus-stop": "", + "cabin": "", + "calendar-events": "", + "campfire": "", + "campground": "", + "campsite": "", + "cannon": "", + "canoe-access": "", + "canoe-portaging": "", + "cans-or-bottles": "", + "caving": "", + "cellular-signal": "", + "cemetery": "", + "chairlift-ski-lift": "", + "chapel": "", + "climbing": "", + "closed-captioning": "", + "coffee": "", + "community-garden": "", + "construction": "", + "cross-country-ski-trail": "", + "customs": "", + "dam": "", + "deer-viewing": "", + "diesel": "", + "directions": "", + "diving": "", + "dog-sledding": "", + "dot": "", + "downhill-skiing": "", + "drinking-water": "", + "driving-tour": "", + "e-bike": "", + "electric-car-charging": "", + "electrical-hookup": "", + "elevator": "", + "emergencies": "", + "emergency-telephone": "", + "entrance": "", + "entrance-station": "", + "event-facility": "", + "exercise-fitness": "", + "falling-rocks": "", + "family-restroom": "", + "fire-extinguisher": "", + "fire-grate": "", + "firewood": "", + "firewood-cutting": "", + "first-aid": "", + "first-come-first-served": "", + "fish-cleaning": "", + "fish-hatchery": "", + "fish-ladder": "", + "fishing": "", + "fishing-license": "", + "fishing-pier": "", + "flagpole": "", + "floating-dump-station": "", + "flower-viewing": "", + "flush-toilets": "", + "food-service": "", + "food-storage": "", + "foraging-gathering": "", + "four-wheel-drive-road": "", + "gas-station": "", + "gate": "", + "generator": "", + "geyser": "", + "golfing": "", + "grill": "", + "guided-tours": "", + "hand-launch-small-boat-launch": "", + "hang-gliding": "", + "historic-feature": "", + "hold-hand-rail": "", + "horseback-riding": "", + "hospital": "", + "hunting": "", + "ice": "", + "ice-cream": "", + "ice-fishing": "", + "ice-skating": "", + "incident": "", + "information": "", + "inline-skating": "", + "interpretive-exhibit": "", + "junior-ranger-program": "", + "kayaking": "", + "kennel": "", + "large-print": "", + "laundry": "", + "library": "", + "life-jackets": "", + "lifeguard": "", + "lighthouse": "", + "litter-receptacle": "", + "live-audio-description": "", + "lock": "", + "lock-bikes": "", + "lockers-storage": "", + "lodging": "", + "lookout-tower": "", + "lounge": "", + "low-vision-access": "", + "maps": "", + "marina": "", + "mechanic": "", + "mens-restroom": "", + "metal-detecting": "", + "metro-station": "", + "mobile-device-charging": "", + "monument": "", + "motorbike-trail": "", + "motorboating": "", + "museum": "", + "newspaper": "", + "no-mobile-devices": "", + "open-captioning": "", + "open-to-the-public": "", + "park-film": "", + "parking": "", + "parking-area": "", + "passes-and-fees": "", + "passport-stamps": "", + "pedal-boating": "", + "pedestrian-crossing": "", + "personal-watercraft": "", + "pets-off-leash": "", + "pets-on-leash": "", + "photography": "", + "picnic-area": "", + "picnic-shelter": "", + "pit-toilet": "", + "playground": "", + "point-of-interest": "", + "post-office": "", + "propane": "", + "propane-bottle-recycling": "", + "quagga-mussel-decontamination-station": "", + "quiet": "", + "radiator-water": "", + "radios": "", + "rail-station": "", + "ranger-led-events": "", + "ranger-station": "", + "rattlesnakes": "", + "recycling": "", + "rentals": "", + "reservations": "", + "residential-building": "", + "restrooms": "", + "river-rafting": "", + "road-segment": "", + "rock-collecting": "", + "rowboating": "", + "rr-xing": "", + "rv-campground": "", + "rv-trailer-hookup": "", + "safety-caution-alerts": "", + "sailing": "", + "sanitary-disposal-station": "", + "scenic-viewpoint": "", + "scuba-diving": "", + "sea-lion-viewing": "", + "seaplane": "", + "self-guiding-trail": "", + "sewer-hookup": "", + "shelter": "", + "shipwreck": "", + "showers": "", + "shuttle-service": "", + "sign": "", + "sign-language-interpretation": "", + "silence-mobile-devices": "", + "skateboarding": "", + "ski-jumping": "", + "sledding": "", + "sleeping-shelter": "", + "slippery-ramp": "", + "slippery-steps": "", + "smoking-area": "", + "snack-bar": "", + "snorkeling": "", + "snowboarding": "", + "snowmobile-trail": "", + "snowshoeing": "", + "souvenir-shop": "", + "spring": "", + "stable": "", + "stagecoach-rides": "", + "stargazing": "", + "statue": "", + "stay-back-from-edge-cliff": "", + "stay-back-from-edge-water": "", + "stay-on-trail": "", + "store": "", + "strollers": "", + "sunny": "", + "supplies": "", + "surfing": "", + "swimming": "", + "table-service": "", + "tactile-exhibit": "", + "technical-rock-climb": "", + "telephone": "", + "tennis": "", + "text-telephone-service": "", + "theater": "", + "theatre-arts": "", + "things-to-do": "", + "ticket-sales": "", + "tidepooling": "", + "toilet": "", + "tornado-shelter": "", + "towing": "", + "trail-segment": "", + "trailer-site": "", + "trailhead": "", + "trailhead-information": "", + "tram-tour": "", + "tramway": "", + "trash-dumpster": "", + "trucks": "", + "tubing": "", + "tunnel": "", + "uneven-walkways": "", + "utv": "", + "vehicle-ferry": "", + "vending-machine": "", + "video-surveillance": "", + "viewing-area": "", + "visitor-center": "", + "volleyball": "", + "volume-control-telephone": "", + "wading": "", + "walk-on-boardwalk": "", + "walking": "", + "watch-for-falling-ice": "", + "water-hookup": "", + "waterfall": "", + "waterfowl": "", + "waterskiing": "", + "webcam": "", + "whale-viewing": "", + "wheelchair-accessible": "", + "wifi": "", + "wilderness": "", + "wind-surfing": "", + "windmill": "", + "wine": "", + "winter-recreation-area": "", + "womens-restroom": "", + "wood-gathering": "", + "young-scientist-program": "", + "zebra-mussel-decontamination-station": "", +};