diff options
| author | Adam Soltys <[email protected]> | 2026-02-27 10:09:16 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-27 10:09:16 -0800 |
| commit | bf7d8d373c11cd7a6e1487175147c9a84e775a98 (patch) | |
| tree | 82fb58568de073ff03dfca3d55d8ce5adcf51608 /src/routes/(app)/locations | |
| parent | 2aa2ac29eb241fc8ded3671e728e578e72652056 (diff) | |
| download | coinos-ui-bf7d8d373c11cd7a6e1487175147c9a84e775a98.tar.gz coinos-ui-bf7d8d373c11cd7a6e1487175147c9a84e775a98.zip | |
map updates
Diffstat (limited to 'src/routes/(app)/locations')
| -rw-r--r-- | src/routes/(app)/locations/+server.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/routes/(app)/locations/+server.ts b/src/routes/(app)/locations/+server.ts index 9980c5fc..ecbb234b 100644 --- a/src/routes/(app)/locations/+server.ts +++ b/src/routes/(app)/locations/+server.ts @@ -1,11 +1,23 @@ import { get } from "$lib/utils"; import { json } from "@sveltejs/kit"; -export async function GET({ setHeaders }) { +export async function GET({ setHeaders, url }) { + const lat = url.searchParams.get("lat"); + const lon = url.searchParams.get("lon"); + const radius = url.searchParams.get("radius"); + const count = url.searchParams.get("count"); + let locations = []; try { - ({ locations } = await get("/locations")); + if (lat && lon) { + const params = new URLSearchParams({ lat, lon }); + if (radius) params.set("radius", radius); + if (count) params.set("count", count); + ({ locations } = await get(`/locations/nearby?${params}`)); + } else { + ({ locations } = await get("/locations")); + } setHeaders({ "cache-control": "public, max-age=600" }); } catch { console.log("failed to fetch locations"); |
