Search: highlight the found spot, open a waypoint's popup, full-height list

A point result (typed coordinates, a geocoded place, a waypoint) leaves
a pulsing marker on the map until the next jump or a click on it. A
result from a layer opens that point's popup as if clicked on the map.
The panel grows to the window height so long result lists fit.
This commit is contained in:
randy committed 2026-11-12 12:13:13 +01:00
1 parent 81e688be9b
commit ba9c40ac3d
4 files changed
+76 -17

No files matched your search

+27 -12
View File
@@ -485,11 +485,23 @@ export class GpxPanelControl {
// Called by the search box (search.js) when a result comes from a file
// that isn't shown yet — same as ticking its box in the tree by hand.
show(path) {
async show(path) {
if (this._visible.has(path)) return;
const checkbox = [...this._treeContainer.querySelectorAll("input[data-path]")].find((input) => input.dataset.path === path);
if (checkbox) checkbox.checked = true;
this._toggleFile(path, true, checkbox);
await this._toggleFile(path, true, checkbox);
}
// Search result picked: show its file, then open the matching point's
// popup as if it had been clicked on the map. Matched by exact
// coordinates (the search index reads the same GeoJSON); a track/line
// result has no popup to open, so it just shows the file.
async showFeature(path, [lng, lat]) {
await this.show(path);
const feature = this._pointsByPath
.get(path)
?.features.find((f) => f.geometry.coordinates[0] === lng && f.geometry.coordinates[1] === lat);
if (feature) this._openPointPopup(path, feature, [lng, lat]);
}
async _toggleFile(path, visible, checkbox) {
@@ -716,16 +728,7 @@ export class GpxPanelControl {
this._map.on("click", layerId, (event) => {
const feature = event.features[0];
if (!feature) return;
// 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();
const popup = new Popup({ closeButton: true, maxWidth: "260px" })
.setLngLat(event.lngLat)
.setHTML(popupHtml(feature.properties, { editable }))
.addTo(this._map);
if (editable) this._wireNoteActions(popup, path, feature);
if (feature) this._openPointPopup(path, feature, event.lngLat);
});
this._map.on("mouseenter", layerId, () => {
this._map.getCanvas().style.cursor = "pointer";
@@ -735,6 +738,18 @@ export class GpxPanelControl {
});
}
_openPointPopup(path, feature, lngLat) {
// 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();
const popup = new Popup({ closeButton: true, maxWidth: "260px" })
.setLngLat(lngLat)
.setHTML(popupHtml(feature.properties, { editable }))
.addTo(this._map);
if (editable) this._wireNoteActions(popup, path, feature);
}
// Edit swaps the popup's content for a plain textarea + Save/Cancel (the
// note's location doesn't change, just its text, so there's no need for
// NoteSaveForm's fuller target-file picker here). Delete just confirms