forked from MapComplete/MapComplete
Search results: add menu, update searchers
This commit is contained in:
parent
9e0ae3321f
commit
ee2b3ce329
10 changed files with 88 additions and 41 deletions
|
|
@ -78,9 +78,6 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
isActive?: Store<boolean>
|
||||
}
|
||||
) {
|
||||
if(layers.length === 0){
|
||||
return
|
||||
}
|
||||
const layersSummed = layers.join("+")
|
||||
const zDiff = 2
|
||||
super(
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ export class RecentSearch {
|
|||
const [lon, lat] = GeoOperations.centerpointCoordinates(selected)
|
||||
const entry = <GeocodeResult>{
|
||||
feature: selected,
|
||||
display_name: selected.properties.name ?? selected.properties.alt_name ?? selected.properties.local_name,
|
||||
osm_id, osm_type,
|
||||
lon, lat,
|
||||
}
|
||||
|
|
@ -70,9 +71,9 @@ export class RecentSearch {
|
|||
}
|
||||
|
||||
addSelected(entry: GeocodeResult) {
|
||||
const id = entry.osm_type+entry.osm_id
|
||||
const id = entry.osm_type + entry.osm_id
|
||||
const arr = [...(this.seenThisSession.data.reverse() ?? []).slice(0, 5)]
|
||||
.filter(e => e.osm_type+e.osm_id !== id)
|
||||
.filter(e => e.osm_type + e.osm_id !== id)
|
||||
|
||||
this.seenThisSession.set([entry, ...arr])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,20 +138,24 @@ export default class SearchState {
|
|||
if (query === "") {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
const geolocationState = this.state.geolocation.geolocationState
|
||||
const searcher = this.state.searchState.geosearch
|
||||
const bounds = this.state.mapProperties.bounds
|
||||
const bbox = this.state.mapProperties.bounds.data
|
||||
try {
|
||||
this.isSearching.set(true)
|
||||
geolocationState?.allowMoving.setData(true)
|
||||
geolocationState?.requestMoment.setData(undefined) // If the GPS is still searching for a fix, we say that we don't want tozoom to it anymore
|
||||
const result = await searcher.search(query, { bbox })
|
||||
if (result.length == 0) {
|
||||
this.feedback.set(Translations.t.general.search.nothing)
|
||||
return false
|
||||
let poi: SearchResult
|
||||
if(this.suggestions.data){
|
||||
poi = this.suggestions.data[0]
|
||||
}else{
|
||||
const results = GeocodingUtils.mergeSimilarResults([].concat(...await Promise.all(this.locationSearchers.map(ls => ls.search(query, { bbox: bounds.data })))))
|
||||
poi = results[0]
|
||||
}
|
||||
const poi = result[0]
|
||||
|
||||
if (poi.category === "theme") {
|
||||
const theme = <MinimalLayoutInformation>poi.payload
|
||||
const url = MoreScreen.createUrlFor(theme)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue