Feature(pwa): add protocol handler

This commit is contained in:
Pieter Vander Vennet 2025-06-16 02:33:37 +02:00
parent 50c2abebdf
commit de74a5dc08
4 changed files with 43 additions and 17 deletions

View file

@ -66,6 +66,21 @@ export default class InitialMapPositioning {
defaultLon,
"The initial/current longitude of the app"
)
const geouri = QueryParameters.GetQueryParameter("geouri", undefined, "Alternative format to set lat/lon; but with an entire geouri instead. ")
console.log("geouri", geouri.data, !!geouri.data)
if (geouri.data) {
try {
const url = new URL("geo:"+decodeURIComponent(geouri.data))
const [latN, lonN] = url.pathname.split(",").map(n => parseFloat(n))
lat.set(latN)
lon.set(lonN)
if(url.searchParams.has("q")){
QueryParameters.GetQueryParameter("q", undefined).set(url.searchParams.get("q"))
}
} catch (e) {
console.warn("Could not parse geoURI:", e)
}
}
this.location = new UIEventSource({ lon: lon.data, lat: lat.data })
// Note: this syncs only in one direction

View file

@ -17,10 +17,11 @@ import { FeatureSource } from "../FeatureSource/FeatureSource"
import { Feature } from "geojson"
import OpenLocationCodeSearch from "../Search/OpenLocationCodeSearch"
import { BBox } from "../BBox"
import { QueryParameters } from "../Web/QueryParameters"
export default class SearchState {
public readonly feedback: UIEventSource<Translation> = new UIEventSource<Translation>(undefined)
public readonly searchTerm: UIEventSource<string> = new UIEventSource<string>("")
public readonly searchTerm: UIEventSource<string>
public readonly searchIsFocused = new UIEventSource(false)
public readonly suggestions: Store<GeocodeResult[]>
public readonly filterSuggestions: Store<FilterSearchResult[]>
@ -36,6 +37,8 @@ export default class SearchState {
constructor(state: ThemeViewState) {
this.state = state
this.searchTerm = QueryParameters.GetQueryParameter("q", "", "The term in the search field")
this.locationSearchers = [
new LocalElementSearch(state, 5),
new CoordinateSearch(),