Search: look through all saved layers and offline hiking trails
GET /api/search (lib/maptool/search.rb) matches feature name and description, case- and diacritics-insensitive, across every file in Tracks & Points (shown or not) and every offline hiking-trails country. Parsed features are cached in memory per file by mtime. The search box now queries local sources and Nominatim side by side, labels each result with where it was found, lets you untick sources, and switches a result's layer on if it was off before zooming to it.
This commit is contained in:
1 parent
2611713489
commit
0051a0337c
10 files changed
+316
-21
No files matched your search
@@ -301,6 +301,7 @@ export class GpxPanelControl {
|
||||
const checkbox = document.createElement("input");
|
||||
checkbox.type = "checkbox";
|
||||
checkbox.checked = this._visible.has(file.path);
|
||||
checkbox.dataset.path = file.path;
|
||||
checkbox.addEventListener("change", () => this._toggleFile(file.path, checkbox.checked, checkbox));
|
||||
// Just the real, as-uploaded name — it used to grow a ".geojson" suffix
|
||||
// once cached (matching the real "<path>.geojson" cache file on disk),
|
||||
@@ -482,6 +483,15 @@ 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) {
|
||||
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);
|
||||
}
|
||||
|
||||
async _toggleFile(path, visible, checkbox) {
|
||||
if (visible) {
|
||||
this._visible.add(path);
|
||||
|
||||
Reference in new issue
Block a user