mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
feat(search): compose Google and Photon through an explicit provider service
This commit is contained in:
commit
57d7f9fc23
30 files changed
+1621
-151
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { createStandalonePlaceSearch } from './placeSearch.js';
|
||||
import { createApplication } from '../app/application.js';
|
||||
import { createStandaloneScene } from './scene.js';
|
||||
import { createStandaloneControls } from './controls.js';
|
||||
@@ -18,19 +19,25 @@ export function createStandaloneApplication({
|
||||
constructed = true;
|
||||
const loadingScreen = document.getElementById('loading-screen');
|
||||
const loaderStatus = loadingScreen.querySelector('.loader-status');
|
||||
let placeSearch;
|
||||
return createApplication({
|
||||
createScene: (context) =>
|
||||
createStandaloneScene({
|
||||
createScene: (context) => {
|
||||
placeSearch = createStandalonePlaceSearch({
|
||||
resolveApiKey: () => googleApiKey,
|
||||
signal: context.signal,
|
||||
});
|
||||
return createStandaloneScene({
|
||||
...context,
|
||||
googleApiKey,
|
||||
cesiumToken,
|
||||
loaderStatus,
|
||||
}),
|
||||
});
|
||||
},
|
||||
createControls: (context) =>
|
||||
createStandaloneControls({ ...context, loaderStatus }),
|
||||
createStandaloneControls({ ...context, loaderStatus, placeSearch }),
|
||||
createData: (context) =>
|
||||
createStandaloneData({ ...context, allowQaRegistration }),
|
||||
createTools: (context) =>
|
||||
createStandaloneTools({ ...context, loadingScreen }),
|
||||
createStandaloneTools({ ...context, loadingScreen, placeSearch }),
|
||||
});
|
||||
}
|
||||
Vendored
+5
-1
@@ -6,10 +6,14 @@ import { initCockpitCloudEffects } from '../cockpitCloudEffects.js';
|
||||
export function createStandaloneControls({
|
||||
scene: { viewer, mapStackController },
|
||||
loaderStatus,
|
||||
placeSearch,
|
||||
defer,
|
||||
}) {
|
||||
// Initialize the style manager (post-processing, HUD, locations, share links)
|
||||
const styleManager = new StyleManager(viewer, { mapStackController });
|
||||
const styleManager = new StyleManager(viewer, {
|
||||
mapStackController,
|
||||
placeSearch,
|
||||
});
|
||||
defer(() => styleManager.orbitController.stop());
|
||||
defer(() => styleManager.hud.destroy());
|
||||
defer(() => styleManager.dispose());
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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 }),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export function createStandaloneTools({
|
||||
controls,
|
||||
data,
|
||||
loadingScreen,
|
||||
placeSearch,
|
||||
signal,
|
||||
defer,
|
||||
}) {
|
||||
@@ -25,7 +26,7 @@ export function createStandaloneTools({
|
||||
const { dataManager } = data;
|
||||
const sceneDirector = new SceneDirector(viewer, styleManager, dataManager);
|
||||
defer(() => sceneDirector.destroy());
|
||||
const annotations = initAnnotations({ viewer, tileset });
|
||||
const annotations = initAnnotations({ viewer, tileset, placeSearch });
|
||||
defer(() => {
|
||||
if (window.__gevAnnotations === annotations) delete window.__gevAnnotations;
|
||||
annotations.destroy();
|
||||
@@ -99,6 +100,7 @@ export function createStandaloneTools({
|
||||
if (window.__godsEyeView === debug) delete window.__godsEyeView;
|
||||
});
|
||||
const voiceCommands = initGevVoiceCommands({
|
||||
placeSearch,
|
||||
viewer,
|
||||
styleManager,
|
||||
dataManager,
|
||||
|
||||
Reference in new issue
Block a user