问题描述
我正试图摆脱围绕 Cesium 构建的 React 网站中的时间线。 javascript 中的命令是:
viewer.timeline.container.style.display = ‘none’
我如何在我的反应返回中翻译它?现在看起来像这样:
<Viewer>
<CameraFlyTo
destination={Cartesian3.fromdegrees(26.0514,44.438,500)}
duration={5}
/>
<Clock
startTime={JulianDate.fromIso8601("2020-12-21")}
currentTime={JulianDate.fromIso8601("2020-12-21")}
stopTime={JulianDate.fromIso8601("2021-01-21")}
clockRange={ClockRange.LOOP_STOP} // loop when we hit the end time
clockStep={ClockStep.SYstem_CLOCK_MULTIPLIER}
multiplier={1} // how much time to advance each tick
shouldAnimate // Animation on by default
/>
</Viewer>
解决方法
在 resium 中,<Viewer />
组件有一个只读布尔属性 timelime
,它将切换时间线的可见性
这应该可以解决问题:
<Viewer timeline={false}>
<CameraFlyTo
destination={Cartesian3.fromDegrees(26.0514,44.438,500)}
duration={5}
/>
...
(虽然它是只读的,但我没有看到关于 <Viewer />
被重新渲染的任何警告)
希望这有效!