From 6182a2856df9aef8c8a7b5ee3a507c1114cb4743 Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Fri, 27 Nov 2026 00:06:20 +0100 Subject: [PATCH] Points: bare waypoints (Google saved places) as small NPS-style dots instead of an empty badge, names as dark labels with a white halo from zoom 10; every library point editable (Edit/Move/Delete) when logged in, not only notes --- public/js/gpx.js | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/public/js/gpx.js b/public/js/gpx.js index f94fd6b..1100c2b 100644 --- a/public/js/gpx.js +++ b/public/js/gpx.js @@ -792,11 +792,28 @@ export class GpxPanelControl { // the coordinate — a square has no natural "tip" the way a pin does, so // default center anchoring is simplest and also means the glyph layer // below needs no offset, just the same center anchor. + // A point with no NPS symbol (a Google saved place, a bare GPX + // waypoint) is a small dot instead, like a place on an NPS map — an + // empty badge read as a big red square. + const single = ["!", ["has", "point_count"]]; + const hasSymbol = ["in", ["get", "icon"], ["literal", POI_ICON_KEYS]]; + this._map.addLayer({ + id: `${pointsId}-dot`, + type: "circle", + source: pointsId, + filter: ["all", single, ["!", hasSymbol]], + paint: { + "circle-radius": ["interpolate", ["linear"], ["zoom"], 6, 3.5, 14, 6], + "circle-color": ["get", "color"], + "circle-stroke-color": "#fff", + "circle-stroke-width": 1.5, + }, + }); this._map.addLayer({ id: `${pointsId}-unclustered`, type: "symbol", source: pointsId, - filter: ["!", ["has", "point_count"]], + filter: ["all", single, hasSymbol], layout: { "icon-image": ["concat", BADGE_IMAGE_PREFIX, ["get", "color"]], "icon-size": MAP_MARKER_SIZE, @@ -811,7 +828,7 @@ export class GpxPanelControl { id: `${pointsId}-unclustered-icon`, type: "symbol", source: pointsId, - filter: ["all", ["!", ["has", "point_count"]], ["in", ["get", "icon"], ["literal", POI_ICON_KEYS]]], + filter: ["all", single, hasSymbol], layout: { "icon-image": ["get", "icon"], "icon-size": POI_ICON_SIZE, @@ -820,8 +837,28 @@ export class GpxPanelControl { }, }); + // Its name beside each point from zoom 10, NPS-map style: dark text + // on a white halo, right of the dot/badge, dropped where it collides. + this._map.addLayer({ + id: `${pointsId}-label`, + type: "symbol", + source: pointsId, + filter: single, + minzoom: 10, + layout: { + "text-field": ["get", "name"], + "text-font": ["Noto Sans Regular"], + "text-size": 12, + "text-anchor": "left", + "text-offset": ["case", hasSymbol, ["literal", [1.4, 0]], ["literal", [0.8, 0]]], + "text-max-width": 10, + }, + paint: { "text-color": "#2b2b2b", "text-halo-color": "#fff", "text-halo-width": 1.5 }, + }); + this._registerClusterInteractivity(pointsId); this._registerPointInteractivity(`${pointsId}-unclustered`, path); + this._registerPointInteractivity(`${pointsId}-dot`, path); } // Clicking a cluster zooms in just far enough to break it apart, the @@ -872,7 +909,9 @@ export class GpxPanelControl { // properties.id is what update/delete target by — a note saved before // that existed (see `rake gpx:backfill_note_ids`) doesn't have one // yet, and offering Edit/Delete for it would just 404. - const editable = feature.properties.category === "Note" && !!feature.properties.id && isLoggedIn(); + // Any point or note kept in the library (it has an id) can be edited; + // a waypoint inside an old uploaded file without one can't. + const editable = !!feature.properties.id && isLoggedIn(); const popup = new Popup({ closeButton: true, maxWidth: "260px" }) .setLngLat(lngLat) .setHTML(popupHtml(feature.properties, { editable, movable: feature.geometry.type === "Point" })) @@ -1077,8 +1116,10 @@ export class GpxPanelControl { `${linesId}-note-line`, `${pointsId}-clusters`, `${pointsId}-cluster-count`, + `${pointsId}-dot`, `${pointsId}-unclustered`, `${pointsId}-unclustered-icon`, + `${pointsId}-label`, ].forEach((layerId) => { if (this._map.getLayer(layerId)) this._map.removeLayer(layerId); });