Add proxied autocomplete for Stadia
This allows me to make the format consistent and to cache the intermediate results, which is useful for speed and testing
This commit is contained in:
parent
b6cfbee102
commit
2d5dca3fb5
11 changed files with 275 additions and 11 deletions
|
|
@ -138,9 +138,11 @@ function handleInput() {
|
|||
|
||||
async function fetchAddressSuggestions(text: string) {
|
||||
try {
|
||||
const url = `https://api.stadiamaps.com/geocoding/v2/autocomplete?text=${encodeURIComponent(
|
||||
text,
|
||||
)}&focus.point.lat=35&focus.point.lon=-115`;
|
||||
const q = encodeURIComponent(text);
|
||||
//const url = `https://api.stadiamaps.com/geocoding/v2/autocomplete?text=${encodeURIComponent(
|
||||
//text,
|
||||
//)}&focus.point.lat=35&focus.point.lon=-115`;
|
||||
const url = `/api/geocode/suggestion?query=${q}`;
|
||||
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
|
@ -183,8 +185,10 @@ function formatAddressDisplay(address: Address): string {
|
|||
const street = props.address_components.street ?? "";
|
||||
const location = props.coarse_location ?? "";
|
||||
return `${num} ${street}, ${location}`.trim();
|
||||
} else {
|
||||
} else if (props.name != "") {
|
||||
return `${props.name ?? ""}, ${props.coarse_location ?? ""}`.trim();
|
||||
} else {
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ interface Properties {
|
|||
precision?: string; // "centroid"
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Geometry {
|
||||
type: string;
|
||||
coordinates: [number, number];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue