Add a scale bar to the map
CI / check (push) Successful in 53s
CI / deploy (push) Successful in 12s

MapLibre's own ScaleControl, bottom-left (attribution already owns
bottom-right) — no custom NPS-style bar needed, the built-in one covers it.
This commit is contained in:
randy committed 2026-09-10 22:14:40 +02:00
1 parent c9561a5489
commit 254e9b4c61
1 file changed
+2
+2
View File
@@ -2,6 +2,7 @@ import {
Map as MaplibreMap, Map as MaplibreMap,
NavigationControl, NavigationControl,
Popup, Popup,
ScaleControl,
addProtocol, addProtocol,
} from "/vendor/maplibre-gl/maplibre-gl.mjs"; } from "/vendor/maplibre-gl/maplibre-gl.mjs";
import { GpxPanelControl } from "/js/gpx.js"; import { GpxPanelControl } from "/js/gpx.js";
@@ -427,6 +428,7 @@ const gnssControl = new GnssControl(map);
// the "GNSS" sidebar icon actually turns it on — not just whenever a // the "GNSS" sidebar icon actually turns it on — not just whenever a
// receiver happens to have a fix. See locate.js. // receiver happens to have a fix. See locate.js.
map.addControl(new LocateControl(gnssControl), "top-left"); map.addControl(new LocateControl(gnssControl), "top-left");
map.addControl(new ScaleControl({ unit: "metric" }), "bottom-left");
// A small inset map showing where the current view sits in context — NPS's // A small inset map showing where the current view sits in context — NPS's
// own overview plugin (docs/nps-resources.adoc's "overview" entry, still on // own overview plugin (docs/nps-resources.adoc's "overview" entry, still on