feat: location selector in route UI
Some checks failed
TrafficCue CI / check (push) Failing after 47s
TrafficCue CI / build (push) Failing after 41s

This commit is contained in:
2025-08-21 15:45:16 +02:00
parent 15e88979d5
commit 03b129f947
5 changed files with 175 additions and 74 deletions

View File

@@ -1,3 +1,5 @@
import { reverseGeocode } from "./services/Search";
export const saved: Record<string, WorldLocation> = $state(
JSON.parse(localStorage.getItem("saved") ?? "{}"),
);
@@ -5,3 +7,14 @@ export const saved: Record<string, WorldLocation> = $state(
export function saveLocations() {
localStorage.setItem("saved", JSON.stringify(saved));
}
export async function geocode(name: string) {
const loc = saved[name];
if(!loc) return;
const geocode = await reverseGeocode(loc);
if(geocode.length == 0) {
return;
}
const feature = geocode[0];
return `${feature.properties.street}${feature.properties.housenumber ? (" " + feature.properties.housenumber) : ""}, ${feature.properties.city}`;
}