forked from MapComplete/MapComplete
Add search previews on the map
This commit is contained in:
parent
1c46a65c84
commit
4f52483a98
19 changed files with 315 additions and 87 deletions
|
|
@ -26,6 +26,7 @@ export default class Constants {
|
|||
"last_click",
|
||||
"favourite",
|
||||
"summary",
|
||||
"search"
|
||||
] as const
|
||||
/**
|
||||
* Special layers which are not included in a theme by default
|
||||
|
|
@ -38,7 +39,7 @@ export default class Constants {
|
|||
"import_candidate",
|
||||
"usersettings",
|
||||
"icons",
|
||||
"filters",
|
||||
"filters"
|
||||
] as const
|
||||
/**
|
||||
* Layer IDs of layers which have special properties through built-in hooks
|
||||
|
|
@ -126,6 +127,7 @@ export default class Constants {
|
|||
"brick_wall_round",
|
||||
"brick_wall_square",
|
||||
"building_office_2",
|
||||
"building_storefront",
|
||||
"bug",
|
||||
"checkmark",
|
||||
"checkmark",
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ export default class LayoutConfig implements LayoutInformation {
|
|||
}
|
||||
}
|
||||
}
|
||||
console.log("Fallthrough", this, tags)
|
||||
console.trace("Fallthrough: could not find the appropraite layer for an object with tags", tags, "within layout", this)
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ export default class LayoutConfig implements LayoutInformation {
|
|||
...json,
|
||||
layers: json.layers.filter((l) => l["id"] !== "favourite"),
|
||||
}
|
||||
const usedImages = json._usedImages
|
||||
const usedImages = jsonNoFavourites._usedImages
|
||||
usedImages.sort()
|
||||
|
||||
this.usedImages = Utils.Dedup(usedImages)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ import Locale from "../UI/i18n/Locale"
|
|||
import Hash from "../Logic/Web/Hash"
|
||||
import { GeoOperations } from "../Logic/GeoOperations"
|
||||
import { CombinedFetcher } from "../Logic/Web/NearbyImagesSearch"
|
||||
import GeocodingProvider from "../Logic/Geocoding/GeocodingProvider"
|
||||
import GeocodingProvider, { GeocodingUtils } from "../Logic/Geocoding/GeocodingProvider"
|
||||
import CombinedSearcher from "../Logic/Geocoding/CombinedSearcher"
|
||||
import CoordinateSearch from "../Logic/Geocoding/CoordinateSearch"
|
||||
import LocalElementSearch from "../Logic/Geocoding/LocalElementSearch"
|
||||
|
|
@ -774,6 +774,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
favourite: this.favourites,
|
||||
summary: this.featureSummary,
|
||||
last_click: this.lastClickObject,
|
||||
search: undefined
|
||||
}
|
||||
|
||||
this.closestFeatures.registerSource(specialLayers.favourite, "favourite")
|
||||
|
|
@ -910,6 +911,34 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
this.selectedElement.setData(this.currentView.features?.data?.[0])
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the appropriate layer - will first try if a special layer matches; if not, a normal layer will be used by delegating to the layout
|
||||
* @param tags
|
||||
*/
|
||||
public getMatchingLayer(properties: Record<string, string>){
|
||||
|
||||
const id = properties.id
|
||||
|
||||
if (id.startsWith("summary_")) {
|
||||
// We don't select 'summary'-objects
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (id === "settings") {
|
||||
return UserRelatedState.usersettingsConfig
|
||||
}
|
||||
if (id.startsWith(LastClickFeatureSource.newPointElementId)) {
|
||||
return this.layout.layers.find((l) => l.id === "last_click")
|
||||
}
|
||||
if (id.startsWith("search_result")) {
|
||||
return GeocodingUtils.searchLayer
|
||||
}
|
||||
if (id === "location_track") {
|
||||
return this.layout.layers.find((l) => l.id === "gps_track")
|
||||
}
|
||||
return this.layout.getMatchingLayer(properties)
|
||||
}
|
||||
|
||||
public async reportError(message: string | Error | XMLHttpRequest) {
|
||||
const isTesting = this.featureSwitchIsTesting.data
|
||||
console.log(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue