优化任务完成之后 的显示 优化实时监控界面的显示逻辑
This commit is contained in:
@@ -1677,14 +1677,37 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
|
||||
handler.setInputAction((movement) => {
|
||||
const picked = viewer.scene.pick(movement.position);
|
||||
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
|
||||
const robot = picked.id.properties.robot.getValue();
|
||||
robot.feStatus == 1 && onCameraClickRef.current?.(robot);
|
||||
}
|
||||
}, window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||
// ========= 增加防护,直接拦截 movement.position undefined =========
|
||||
if (!movement || !movement.position) return;
|
||||
|
||||
handler.setInputAction((movement) => {
|
||||
const picked = viewer.scene.pick(movement.position);
|
||||
let robot = null;
|
||||
if (window.Cesium.defined(picked) && picked.id) {
|
||||
const robotProp = picked.id.properties?.robot;
|
||||
robot = robotProp ? (typeof robotProp.getValue === "function" ? robotProp.getValue() : robotProp) : (picked.id.robotData || null);
|
||||
if (!robot) {
|
||||
const pickedCarto = viewer.scene.globe.pick(movement.position, viewer.scene);
|
||||
if (window.Cesium.defined(pickedCarto)) {
|
||||
const clon = window.Cesium.Math.toDegrees(pickedCarto.longitude);
|
||||
const clat = window.Cesium.Math.toDegrees(pickedCarto.latitude);
|
||||
let best = null;
|
||||
let bestDist = 0.002;
|
||||
devices.forEach(d => {
|
||||
const raw = d?.locationMessage || d?.lastRunningStatus || {};
|
||||
const dlon = Number(raw.longitude);
|
||||
const dlat = Number(raw.latitude);
|
||||
if (!isFinite(dlon) || !isFinite(dlat)) return;
|
||||
const dist = Math.hypot(dlon - clon, dlat - clat);
|
||||
if (dist < bestDist) { bestDist = dist; best = d; }
|
||||
});
|
||||
robot = best;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('点击地图,拾取到设备', robot);
|
||||
if (robot) {
|
||||
onCameraClickRef.current?.(robot);
|
||||
}
|
||||
if (from !== "deviceStatus")
|
||||
return;
|
||||
const cartesian = viewer.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid);
|
||||
@@ -1696,6 +1719,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
onMarkPointRef.current?.({ lon, lat });
|
||||
}, window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||
|
||||
|
||||
|
||||
|
||||
if (onClearDraw) {
|
||||
onClearDraw(clearDrawingPath);
|
||||
}
|
||||
@@ -1703,7 +1729,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
return () => {
|
||||
handler.destroy();
|
||||
};
|
||||
}, [drawPoints, from]);
|
||||
}, [drawPoints, from, devices]);
|
||||
|
||||
//useEffect(() => {
|
||||
// const viewer = viewerRef.current;
|
||||
@@ -1875,6 +1901,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
||||
let headingDeg = Number(realtimePosition.heading);
|
||||
|
||||
rotation = Cesium.Math.toRadians(headingDeg);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user