mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor: compose configurable geocoding and route services
This commit is contained in:
1 parent
3b91feffdc
commit
8b36c28b06
25 files changed
+764
-211
No files matched your search
@@ -1,32 +1 @@
|
||||
import {
|
||||
createPlaceSearch,
|
||||
createGoogleGeocoder,
|
||||
createPhotonGeocoder,
|
||||
} from '../search/index.js';
|
||||
|
||||
/** Google first when configured, then keyless Photon; transport stays local to setup. */
|
||||
export function createStandalonePlaceSearch({
|
||||
resolveApiKey,
|
||||
fetchImpl = (...args) => fetch(...args),
|
||||
signal,
|
||||
} = {}) {
|
||||
return createPlaceSearch({
|
||||
signal,
|
||||
providers: [
|
||||
createGoogleGeocoder({
|
||||
request(query, { bias, signal }) {
|
||||
const key = resolveApiKey?.();
|
||||
if (!key) return null;
|
||||
const url = new URL(
|
||||
'https://maps.googleapis.com/maps/api/geocode/json',
|
||||
);
|
||||
url.searchParams.set('address', query);
|
||||
url.searchParams.set('key', key);
|
||||
if (bias) url.searchParams.set('bounds', bias);
|
||||
return fetchImpl(url.toString(), { signal });
|
||||
},
|
||||
}),
|
||||
createPhotonGeocoder({ fetchImpl }),
|
||||
],
|
||||
});
|
||||
}
|
||||
export { createDefaultPlaceSearch as createStandalonePlaceSearch } from '../search/defaults.js';
|
||||
Reference in new issue
Block a user