mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge main and switch Cesium and Navara in place through Vue
Preserve the camera, map source and layer selection across engine sessions. Restore the previous engine if startup fails and retain local history navigation.
This commit is contained in:
commit
b8f4d097c4
1691 files changed
+225876
-41594
No files matched your search
Vendored
+1
-32
@@ -1,40 +1,9 @@
|
||||
import { createApplicationControls } from '../app/controls.js';
|
||||
import { getStandaloneCatalog } from './catalog.js';
|
||||
import { ENGINE_STORAGE_KEY } from '../app/engineChoice.js';
|
||||
|
||||
export function createStandaloneControls(options) {
|
||||
const controls = createApplicationControls({
|
||||
return createApplicationControls({
|
||||
catalog: options?.catalog ?? getStandaloneCatalog(),
|
||||
...options,
|
||||
});
|
||||
const select = document.getElementById('globe-engine');
|
||||
const container = document.getElementById('globe-engine-control');
|
||||
if (select && container) {
|
||||
const current = options.scene.engine.kind;
|
||||
select.value = current;
|
||||
const switchEngine = () => {
|
||||
const next = select.value;
|
||||
if (next === current || !['cesium', 'navara'].includes(next)) return;
|
||||
controls.styleManager.shareLinkManager.flush();
|
||||
const url = new URL(window.location.href);
|
||||
// Keep Back meaningful even when this visit began without ?engine=.
|
||||
url.searchParams.set('engine', current);
|
||||
window.history.replaceState(window.history.state, '', url);
|
||||
url.searchParams.set('engine', next);
|
||||
try {
|
||||
window.localStorage.setItem(ENGINE_STORAGE_KEY, next);
|
||||
} catch {
|
||||
// The explicit URL also works when storage is blocked.
|
||||
}
|
||||
select.value = current;
|
||||
window.location.assign(url);
|
||||
};
|
||||
select.addEventListener('change', switchEngine);
|
||||
container.hidden = false;
|
||||
options.defer(() => {
|
||||
select.removeEventListener('change', switchEngine);
|
||||
container.hidden = true;
|
||||
});
|
||||
}
|
||||
return controls;
|
||||
}
|
||||
Reference in new issue
Block a user