地图上显示无人机
This commit is contained in:
@@ -692,16 +692,16 @@ export default function CesiumMap({ realtimePosition, pathPoints = [], devices =
|
||||
viewer.scene.requestRenderMode = true; // 👈 加这个(只在需要时渲染)
|
||||
viewer.scene.globe.enableLighting = false;
|
||||
|
||||
viewer.camera.flyTo({
|
||||
// 中国中心大致坐标 + 合适高度(200万米)
|
||||
destination: window.Cesium.Cartesian3.fromDegrees(103.84, 31.15, 2000000),
|
||||
orientation: {
|
||||
heading: window.Cesium.Math.toRadians(0),
|
||||
pitch: window.Cesium.Math.toRadians(-90),
|
||||
roll: 0
|
||||
},
|
||||
duration: 0 // 初始化直接到位,无需动画
|
||||
});
|
||||
//viewer.camera.flyTo({
|
||||
// // 中国中心大致坐标 + 合适高度(200万米)
|
||||
// destination: window.Cesium.Cartesian3.fromDegrees(103.84, 31.15, 2000000),
|
||||
// orientation: {
|
||||
// heading: window.Cesium.Math.toRadians(0),
|
||||
// pitch: window.Cesium.Math.toRadians(-90),
|
||||
// roll: 0
|
||||
// },
|
||||
// duration: 0 // 初始化直接到位,无需动画
|
||||
//});
|
||||
|
||||
|
||||
try { fetchPublishedLayers() } catch (e) { }
|
||||
@@ -776,6 +776,7 @@ export default function CesiumMap({ realtimePosition, pathPoints = [], devices =
|
||||
|
||||
|
||||
devices.forEach((device, index) => {
|
||||
console.log(device, "devicedd")
|
||||
|
||||
const raw = device?.lastRunningStatus || {};
|
||||
const parsed = parseLngLat(raw.longitude, raw.latitude);
|
||||
|
||||
@@ -242,12 +242,12 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<div><span style={{ color: '#1890ff' }}>———</span> 巡检航线</div>
|
||||
<div><span style={{ color: '#fa8c16' }}>———</span> 机器人路径</div>
|
||||
<div><span style={{ color: '#52c41a' }}>———</span> 清洗路径</div>
|
||||
<div><span style={{ color: '#52c41a' }}>●</span> 设备位置</div>
|
||||
<div>🚗 设备位置</div>
|
||||
<div><span style={{ color: '#1890ff' }}>●</span> 补给/充电点</div>
|
||||
<div><span style={{ color: '#ff4d4f' }}>■</span> 障碍/禁入区</div>
|
||||
</div>
|
||||
</div>
|
||||
<CesiumMap />
|
||||
<CesiumMap devices={devicesAll} />
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ const DeviceStatusSettingPage = ({ serialNumber }) => (
|
||||
<div style={{ padding: 20 }}>
|
||||
<h2>设置状态页面</h2>
|
||||
<p>当前查看设备序列号: <span style={{ fontWeight: 'bold', color: '#1890ff' }}>{serialNumber || '未选择设备'}</span></p>
|
||||
{/* 这里后续可以根据 serialNumber 加载具体的设备状态详情 */}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -33,7 +32,7 @@ export default function DeviceIndexPage() {
|
||||
{ key: 'wayLineTask', label: '航线任务', icon: <AimOutlined /> },
|
||||
];
|
||||
|
||||
// 👇 核心修复:同时请求 + 同时合并
|
||||
// 👇 核心:给无人机补全 lastRunningStatus + type: 'plane'
|
||||
const fetchAllData = async () => {
|
||||
if (!userInfo?.username) return;
|
||||
|
||||
@@ -44,17 +43,37 @@ export default function DeviceIndexPage() {
|
||||
getPlaneDeviceList(),
|
||||
]);
|
||||
|
||||
// 2. 处理设备数据
|
||||
// 2. 处理普通设备
|
||||
const devData = deviceRes?.code === 200 ? (deviceRes.data || []) : [];
|
||||
const planeData = planeRes?.code === 200 ? (planeRes.data?.detail || []) : [];
|
||||
|
||||
// 3. 处理无人机 + 自动补全地图需要的字段(关键改动)
|
||||
let planeData = planeRes?.code === 200 ? (planeRes.data?.detail || []) : [];
|
||||
|
||||
// ====================== ✅ 核心改造 ======================
|
||||
planeData = planeData.map(item => ({
|
||||
...item,
|
||||
// 给无人机统一设置 type: plane
|
||||
type: 'plane',
|
||||
// 自动生成 lastRunningStatus(经纬度取无人机自身字段)
|
||||
lastRunningStatus: {
|
||||
longitude: item.longitude || 0,
|
||||
latitude: item.latitude || 0,
|
||||
},
|
||||
// 兼容地图取设备名/序列号
|
||||
deviceAlias: item.drone_callsign || item.device_sn
|
||||
|| '无人机',
|
||||
|
||||
}));
|
||||
// ========================================================
|
||||
|
||||
setDevices(devData);
|
||||
setPlaneDevices(planeData);
|
||||
|
||||
// 合并所有设备
|
||||
const all = [...devData, ...planeData];
|
||||
setDevicesAll(all);
|
||||
|
||||
// 如果当前没选中,默认选第一个
|
||||
// 默认选中第一个
|
||||
if (!selectedSn && all.length > 0) {
|
||||
setSelectedSn(all[0].device_sn || all[0].serialNumber);
|
||||
}
|
||||
@@ -100,7 +119,6 @@ export default function DeviceIndexPage() {
|
||||
<div style={{ display: 'flex', paddingBottom: "4px" }}>
|
||||
<div style={{ padding: '8px 12px 0', flexShrink: 0 }}>
|
||||
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>装备控制</Typography.Title>
|
||||
{/*<Text type="secondary" style={{ fontSize: '12px' }}>装备总览、状态监控与参数配置</Text>*/}
|
||||
</div>
|
||||
|
||||
<Header style={{
|
||||
@@ -117,8 +135,8 @@ export default function DeviceIndexPage() {
|
||||
border: '0',
|
||||
height: 40,
|
||||
lineHeight: '40px',
|
||||
background: 'transparent', // 这里直接写,不需要 !important
|
||||
backgroundColor: 'transparent' // 兼容更好
|
||||
background: 'transparent',
|
||||
backgroundColor: 'transparent'
|
||||
}} />
|
||||
</Header>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user