Preview a search result or route point on hover / press-and-hold, back on leave, committed on click

This commit is contained in:
randy committed 2026-11-13 22:45:42 +01:00
1 parent abde7fe5f9
commit b80575828a
5 files changed
+123

No files matched your search

+5
View File
@@ -2,6 +2,7 @@ import { Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs";
import { SEARCH_ICON } from "/js/icons.js";
import { escapeHtml } from "/js/gpx.js";
import { addRoutePoint } from "/js/panels.js";
import { wirePreview } from "/js/preview.js";
const NOMINATIM_API = "https://nominatim.openstreetmap.org/search";
// "lat, lng" / "lat lng" decimal degrees — the same plain-text shape the
@@ -225,6 +226,10 @@ export class SearchControl {
});
});
this._resultsEl.querySelectorAll(".search-panel__result").forEach((el) => {
const result = this._results[Number(el.dataset.index)];
if (result.bbox || result.lat != null) {
wirePreview(this._map, el, () => (result.lat != null ? { lngLat: [result.lng, result.lat] } : { bbox: result.bbox }));
}
el.addEventListener("click", () => {
const result = this._results[Number(el.dataset.index)];
result.open?.();