mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 16:06:19 -05:00
Map search added to global search. Preview cards are displayed for all results in new Map tab.
Map viewer has simple search. Map search databases can be downloaded from CDN, or built locally. Map searches can be built offline, but will not have enriched things like state names downloaded from Wikidata.
This commit is contained in:
parent
aaa3c0aff7
commit
c726654de9
21 changed files with 1831 additions and 62 deletions
|
|
@ -1580,6 +1580,44 @@ export async function setMapDefaultLocation(lat, lon, zoom) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function searchMap(query, limit = 12, offset = 0, lat = null, lon = null) {
|
||||
let url = `${API_URI}/map/search?q=${encodeURIComponent(query)}&limit=${limit}&offset=${offset}`;
|
||||
if (lat !== null && lon !== null) {
|
||||
url += `&lat=${lat}&lon=${lon}`;
|
||||
}
|
||||
const response = await apiGet(url);
|
||||
if (!response.ok) {
|
||||
return {results: [], total: 0};
|
||||
}
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function getMapSearchStatus() {
|
||||
const response = await apiGet(`${API_URI}/map/search/status`);
|
||||
if (!response.ok) {
|
||||
return {indexed: [], missing: []};
|
||||
}
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function searchEstimateMap(search_str) {
|
||||
if (!search_str) return {mapPlaces: 0};
|
||||
const response = await apiGet(`${API_URI}/map/search/estimate?q=${encodeURIComponent(search_str)}`);
|
||||
if (!response.ok) return {mapPlaces: 0};
|
||||
const data = await response.json();
|
||||
return {mapPlaces: data.map_places || 0};
|
||||
}
|
||||
|
||||
export async function rebuildMapSearchIndex(filename) {
|
||||
const response = await apiPost(`${API_URI}/map/search/rebuild/${encodeURIComponent(filename)}`);
|
||||
if (!response.ok) {
|
||||
const message = await getErrorMessage(response, 'Could not rebuild search index');
|
||||
toast({type: 'error', title: 'Map Error', description: message, time: 5000});
|
||||
} else {
|
||||
toast({type: 'success', title: 'Search Index', description: 'Search index build started', time: 3000});
|
||||
}
|
||||
}
|
||||
|
||||
export async function clearCompletedDownloads() {
|
||||
const response = await apiPost(`${API_URI}/download/clear_completed`);
|
||||
if (!response.ok) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue