Route panel: points from search, GPS and library points, reordering, editing a saved route
This commit is contained in:
1 parent
3146478c23
commit
abde7fe5f9
10 files changed
+214
-25
No files matched your search
@@ -1,6 +1,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";
|
||||
|
||||
const NOMINATIM_API = "https://nominatim.openstreetmap.org/search";
|
||||
// "lat, lng" / "lat lng" decimal degrees — the same plain-text shape the
|
||||
@@ -208,6 +209,7 @@ export class SearchControl {
|
||||
result.status
|
||||
? `<li class="search-panel__status">${escapeHtml(result.status)}</li>`
|
||||
: `<li class="search-panel__result" data-index="${i}">
|
||||
${result.lat != null || result.bbox ? `<button type="button" class="search-panel__route" title="Add to route" aria-label="Add to route">+</button>` : ""}
|
||||
${escapeHtml(result.name)}
|
||||
<span class="search-panel__where">${escapeHtml(
|
||||
[result.where, result.distanceKm != null && formatKm(result.distanceKm)].filter(Boolean).join(" · "),
|
||||
@@ -215,6 +217,13 @@ export class SearchControl {
|
||||
</li>`,
|
||||
)
|
||||
.join("") + tail;
|
||||
this._resultsEl.querySelectorAll(".search-panel__route").forEach((button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
const { lat, lng, bbox, name } = this._results[Number(button.closest("li").dataset.index)];
|
||||
addRoutePoint(lat != null ? [lng, lat] : [(bbox[0] + bbox[2]) / 2, (bbox[1] + bbox[3]) / 2], name);
|
||||
});
|
||||
});
|
||||
this._resultsEl.querySelectorAll(".search-panel__result").forEach((el) => {
|
||||
el.addEventListener("click", () => {
|
||||
const result = this._results[Number(el.dataset.index)];
|
||||
|
||||
Reference in new issue
Block a user