fix(map): restore subject flight and search inset
This commit is contained in:
@@ -375,6 +375,7 @@ export type CesiumMapRendererHandle = {
|
||||
getCameraView: () => MapCameraView | null;
|
||||
fitRuntimeEntities: (entityIds?: string[]) => boolean;
|
||||
focusRuntimeEntity: (entityId: string) => boolean;
|
||||
focusSubjectCoordinates: (longitude: number, latitude: number) => boolean;
|
||||
focusCoordinates: (longitude: number, latitude: number) => boolean;
|
||||
focusGridSector: (sector: GridSectorSelection) => boolean;
|
||||
focusGridMajorTile: (tile: GridMajorTileSelection) => boolean;
|
||||
@@ -2744,6 +2745,25 @@ export const CesiumMapRenderer = forwardRef<CesiumMapRendererHandle, {
|
||||
return true;
|
||||
}, [runtimeEntities]);
|
||||
|
||||
const focusSubjectCoordinates = useCallback((longitude: number, latitude: number) => {
|
||||
const viewer = viewerRef.current;
|
||||
if (!viewer || viewer.isDestroyed()
|
||||
|| !Number.isFinite(longitude) || longitude < -180 || longitude > 180
|
||||
|| !Number.isFinite(latitude) || latitude < -90 || latitude > 90) return false;
|
||||
|
||||
// Selection can make a filtered subject visible and request navigation in
|
||||
// the same React tick. In that case Cesium has not rebuilt its data source
|
||||
// yet, so entity lookup cannot be the only way to fly to the subject.
|
||||
// Coordinates from the authorized search/runtime fact provide the same
|
||||
// explicit, inspectable camera composition without clearing user filters.
|
||||
const target = Cartesian3.fromDegrees(longitude, latitude, 0, viewer.scene.globe.ellipsoid);
|
||||
viewer.camera.flyToBoundingSphere(new BoundingSphere(target, 1), {
|
||||
duration: 0.45,
|
||||
offset: new HeadingPitchRange(0, -0.9, 8_000),
|
||||
});
|
||||
return true;
|
||||
}, []);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
startSpiralAnimation,
|
||||
stopSpiralAnimation,
|
||||
@@ -2754,9 +2774,10 @@ export const CesiumMapRenderer = forwardRef<CesiumMapRendererHandle, {
|
||||
fitRuntimeEntities,
|
||||
focusCoordinates,
|
||||
focusRuntimeEntity,
|
||||
focusSubjectCoordinates,
|
||||
focusGridSector,
|
||||
focusGridMajorTile,
|
||||
}), [fitRuntimeEntities, focusCoordinates, focusGridMajorTile, focusGridSector, focusRuntimeEntity, startSpiralAnimation, stopSpiralAnimation]);
|
||||
}), [fitRuntimeEntities, focusCoordinates, focusGridMajorTile, focusGridSector, focusRuntimeEntity, focusSubjectCoordinates, startSpiralAnimation, stopSpiralAnimation]);
|
||||
|
||||
useEffect(() => {
|
||||
const stopForPageLeave = () => stopSpiralAnimation("stopped");
|
||||
|
||||
Reference in New Issue
Block a user