mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
feat(ui): switch between Cesium and Navara in Visual Presets
Remember the chosen engine and restore the current view after navigation. Keep the standalone JavaScript UI and retire the Dioxus migration and Cesium removal milestones.
This commit is contained in:
1 parent
dc7a7c4d53
commit
1da65dc264
7 files changed
+171
-1
No files matched your search
@@ -522,6 +522,12 @@ export class ShareLinkManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** Save the current view before leaving the page. */
|
||||
flush() {
|
||||
clearTimeout(this._debounceTimer);
|
||||
this._updateHash();
|
||||
}
|
||||
|
||||
_scheduleUpdate() {
|
||||
if (this._destroyed || this._initialRestorePending) return;
|
||||
clearTimeout(this._debounceTimer);
|
||||
|
||||
Vendored
+33
-1
@@ -1,8 +1,40 @@
|
||||
import { createApplicationControls } from '../app/controls.js';
|
||||
import { getStandaloneCatalog } from './catalog.js';
|
||||
import { ENGINE_STORAGE_KEY } from '../app/engineChoice.js';
|
||||
|
||||
export function createStandaloneControls(options) {
|
||||
return createApplicationControls({
|
||||
const controls = 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;
|
||||
}
|
||||
@@ -824,6 +824,15 @@
|
||||
}
|
||||
|
||||
/* Map Source tiles live with Visual Presets in the bottom command tray. */
|
||||
#globe-engine-control label {
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
#globe-engine:focus-visible {
|
||||
outline: 2px solid currentColor;
|
||||
}
|
||||
|
||||
.map-source-section {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
|
||||
@@ -49,6 +49,14 @@
|
||||
<span class="btn-key">7</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="globe-engine-control" hidden>
|
||||
<label class="map-source-heading" for="globe-engine">GLOBE ENGINE
|
||||
<select class="pp-select" id="globe-engine">
|
||||
<option value="cesium">Cesium</option>
|
||||
<option value="navara">Navara</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<section class="map-source-section" aria-labelledby="map-source-label">
|
||||
<div class="map-source-heading">
|
||||
<span id="map-source-label">MAP SOURCE</span>
|
||||
|
||||
Reference in new issue
Block a user