天气窗口与执行约束 温度和速度显示
This commit is contained in:
@@ -706,15 +706,59 @@ export default function CesiumMap({ realtimePosition, pathPoints = [], devices =
|
||||
};
|
||||
}, []);
|
||||
|
||||
const focusEntityRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!viewerRef.current || !focusLocation) return;
|
||||
if (!viewerRef.current || !focusLocation) {
|
||||
if (focusEntityRef.current) {
|
||||
viewerRef.current?.entities.remove(focusEntityRef.current);
|
||||
focusEntityRef.current = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
const viewer = viewerRef.current;
|
||||
const Cesium = window.Cesium;
|
||||
|
||||
// 选择图片
|
||||
let image = carImg;
|
||||
if (focusLocation.type === "plane" || focusLocation.type === "drone") {
|
||||
image = planeImg;
|
||||
} else if (focusLocation.type === "robot") {
|
||||
image = droneInspectImg;
|
||||
} else if (focusLocation.type === "mower") {
|
||||
image = carImg;
|
||||
}
|
||||
|
||||
// 如果已经有 focusEntity,先移除
|
||||
if (focusEntityRef.current) {
|
||||
viewer.entities.remove(focusEntityRef.current);
|
||||
}
|
||||
|
||||
// 添加新的 focusEntity
|
||||
focusEntityRef.current = viewer.entities.add({
|
||||
position: Cesium.Cartesian3.fromDegrees(Number(focusLocation.lon), Number(focusLocation.lat), 0),
|
||||
billboard: {
|
||||
image: image,
|
||||
width: 60,
|
||||
height: 60,
|
||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
},
|
||||
label: {
|
||||
text: focusLocation.name,
|
||||
font: "12px sans-serif",
|
||||
pixelOffset: new Cesium.Cartesian2(0, -80),
|
||||
fillColor: Cesium.Color.YELLOW,
|
||||
showBackground: true,
|
||||
backgroundColor: Cesium.Color.BLACK.withAlpha(0.6)
|
||||
}
|
||||
});
|
||||
|
||||
viewer.camera.flyTo({
|
||||
destination: window.Cesium.Cartesian3.fromDegrees(Number(focusLocation.lon), Number(focusLocation.lat), focusLocation.height),
|
||||
destination: Cesium.Cartesian3.fromDegrees(Number(focusLocation.lon), Number(focusLocation.lat), focusLocation.height || 800),
|
||||
orientation: {
|
||||
heading: window.Cesium.Math.toRadians(0.0),
|
||||
pitch: window.Cesium.Math.toRadians(-90.0),
|
||||
heading: Cesium.Math.toRadians(0.0),
|
||||
pitch: Cesium.Math.toRadians(-90.0),
|
||||
roll: 0.0,
|
||||
},
|
||||
duration: 1.5
|
||||
|
||||
Reference in New Issue
Block a user