Search: fix disabling/enabling layers

This commit is contained in:
Pieter Vander Vennet 2024-09-18 22:53:30 +02:00
parent c92c37168a
commit 333619a127

View file

@ -39,7 +39,7 @@ export default class SearchState {
new LocalElementSearch(state, 5), new LocalElementSearch(state, 5),
new CoordinateSearch(), new CoordinateSearch(),
new OpenStreetMapIdSearch(state), new OpenStreetMapIdSearch(state),
new PhotonSearch(), // new NominatimGeocoding(), new PhotonSearch() // new NominatimGeocoding(),
] ]
const bounds = state.mapProperties.bounds const bounds = state.mapProperties.bounds
@ -49,7 +49,7 @@ export default class SearchState {
} }
return this.locationSearchers.map(ls => ls.suggest(search, { bbox: bounds.data })) return this.locationSearchers.map(ls => ls.suggest(search, { bbox: bounds.data }))
}, [bounds], }, [bounds]
) )
this.suggestionsSearchRunning = suggestionsList.bind(suggestions => { this.suggestionsSearchRunning = suggestionsList.bind(suggestions => {
if (suggestions === undefined) { if (suggestions === undefined) {
@ -58,7 +58,7 @@ export default class SearchState {
return Stores.concat(suggestions).map(suggestions => suggestions.some(list => list === undefined)) return Stores.concat(suggestions).map(suggestions => suggestions.some(list => list === undefined))
}) })
this.suggestions = suggestionsList.bindD(suggestions => this.suggestions = suggestionsList.bindD(suggestions =>
Stores.concat(suggestions).map(suggestions => CombinedSearcher.merge(suggestions)), Stores.concat(suggestions).map(suggestions => CombinedSearcher.merge(suggestions))
) )
const themeSearch = new ThemeSearch(state) const themeSearch = new ThemeSearch(state)
@ -108,17 +108,14 @@ export default class SearchState {
private async applyFilter(payload: FilterSearchResult[]) { private async applyFilter(payload: FilterSearchResult[]) {
const state = this.state const state = this.state
const layers = payload.map(fsr => fsr.layer.id) const layersToShow = payload.map(fsr => fsr.layer.id)
console.log("Layers to show are", layersToShow)
for (const [name, otherLayer] of state.layerState.filteredLayers) { for (const [name, otherLayer] of state.layerState.filteredLayers) {
const layer = otherLayer.layerDef const layer = otherLayer.layerDef
if (!layer.isNormal()) { if (!layer.isNormal()) {
continue continue
} }
if(otherLayer.layerDef.minzoom > state.mapProperties.minzoom.data) { otherLayer.isDisplayed.setData(layersToShow.indexOf(layer.id) >= 0)
// Currently not displayed, we don't hide
continue
}
otherLayer.isDisplayed.setData(layers.indexOf(layer.id) > 0)
} }
for (const { filter, index, layer } of payload) { for (const { filter, index, layer } of payload) {
const flayer = state.layerState.filteredLayers.get(layer.id) const flayer = state.layerState.filteredLayers.get(layer.id)