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

This commit is contained in:
randy committed 2026-11-18 23:01:13 +01:00
1 parent 6faabca93d
commit 085c14beca
10 files changed
+551 -279

No files matched your search

+33 -11
View File
@@ -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 = `
<input type="text" class="notes-panel__title" placeholder="Title">
<div class="notes-panel__icons">
<button type="button" class="notes-panel__icon-option active" data-icon="" title="No icon">${NOTE_PIN_ICON}</button>
${Object.keys(POI_ICONS)
.map(
(key) =>
`<button type="button" class="notes-panel__icon-option" data-icon="${key}" title="${escapeAttr(ICON_LABELS[key] || key)}">${POI_ICONS[key]}</button>`,
)
.join("")}
<div class="notes-panel__icon-picker">
<input type="search" class="notes-panel__icon-filter" placeholder="Find an icon (${PICKER_ICONS.length})">
<div class="notes-panel__icons">
<button type="button" class="notes-panel__icon-option active" data-icon="" title="No icon">${NOTE_PIN_ICON}</button>
${PICKER_ICONS.map(
([key, label]) =>
`<button type="button" class="notes-panel__icon-option" data-icon="${key}" title="${escapeAttr(label)}">${POI_ICONS[key]}</button>`,
).join("")}
</div>
</div>
<textarea class="notes-panel__body" rows="3" placeholder="Details (optional) — **bold**, *italic*, links"></textarea>
<select class="notes-panel__target"></select>
@@ -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