修复地图
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Layout, Menu, Button, Space, Select, Avatar, Card, Tag
|
Layout, Menu, Button, Space, Select, Avatar, Card, Tag
|
||||||
@@ -86,7 +86,6 @@ export default function AppLayout() {
|
|||||||
|
|
||||||
list.forEach(item => {
|
list.forEach(item => {
|
||||||
map.set(item.menuId, {
|
map.set(item.menuId, {
|
||||||
...item,
|
|
||||||
key: item.path,
|
key: item.path,
|
||||||
label: item.menuName,
|
label: item.menuName,
|
||||||
icon: getIcon(item.path),
|
icon: getIcon(item.path),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||||
import carImg from '../assets/images/carplane.png';
|
import carImg from '../assets/images/carplane.png';
|
||||||
import inspectImg from "../assets/images/inspectCar.png"
|
import inspectImg from "../assets/images/inspectCar.png"
|
||||||
import planeImg from '../assets/images/planeicon.png';
|
import planeImg from '../assets/images/planeicon.png';
|
||||||
@@ -39,6 +39,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const planLineRef = useRef(null); // points 规划航线
|
const planLineRef = useRef(null); // points 规划航线
|
||||||
const navLineRef = useRef(null); // 完成点实时轨迹
|
const navLineRef = useRef(null); // 完成点实时轨迹
|
||||||
const markedPointsRef = useRef([]); // 标记点实体
|
const markedPointsRef = useRef([]); // 标记点实体
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
|
||||||
const realtimeEntityRef = useRef(null);
|
const realtimeEntityRef = useRef(null);
|
||||||
const realtimeLineRef = useRef(null);
|
const realtimeLineRef = useRef(null);
|
||||||
@@ -200,7 +202,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const validPoints = points.filter(p => {
|
const validPoints = points?.filter(p => {
|
||||||
|
|
||||||
const lon = Number(p.lng);
|
const lon = Number(p.lng);
|
||||||
const lat = Number(p.lat);
|
const lat = Number(p.lat);
|
||||||
@@ -343,8 +345,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
}
|
}
|
||||||
}, [markedPoints]);
|
}, [markedPoints]);
|
||||||
|
|
||||||
function showRobotTooltip(tooltip, robot, position) {
|
function showRobotTooltip(tooltip, robot, position, t) {
|
||||||
const { t } = useTranslation();
|
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
1: { text: t('common.working'), color: "#10b981" },
|
1: { text: t('common.working'), color: "#10b981" },
|
||||||
2: { text: t('devices.idle'), color: "#f59e0b" },
|
2: { text: t('devices.idle'), color: "#f59e0b" },
|
||||||
@@ -484,7 +485,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
!isNaN(Number(realtimePosition.lon)) &&
|
!isNaN(Number(realtimePosition.lon)) &&
|
||||||
!isNaN(Number(realtimePosition.lat));
|
!isNaN(Number(realtimePosition.lat));
|
||||||
|
|
||||||
const hasTrack = points && points.length > 0;
|
const hasTrack = (points && points.length > 0);
|
||||||
|
|
||||||
if (hasRealtime) return "realtime";
|
if (hasRealtime) return "realtime";
|
||||||
if (hasTrack) return "track";
|
if (hasTrack) return "track";
|
||||||
@@ -495,9 +496,12 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const layerIdentifier = `${workspace}:${layerName}`;
|
const layerIdentifier = `${workspace}:${layerName}`;
|
||||||
let baseUrl = wmsUrl;
|
let baseUrl = wmsUrl;
|
||||||
const cesiumLayers = [];
|
const cesiumLayers = [];
|
||||||
if (index == 2 && from == "other") {
|
//if (index == 2 && from == "other") {
|
||||||
flyToLayer(layerIdentifier, baseUrl, 100);
|
// //flyToLayer(layerIdentifier, baseUrl, 100);
|
||||||
}
|
//}
|
||||||
|
//if (index == 0 && from == "other") {
|
||||||
|
// flyToLayer(layerIdentifier, baseUrl, 100);
|
||||||
|
//}
|
||||||
//getLayerBoundsAndFit(wmsUrl, layerName);
|
//getLayerBoundsAndFit(wmsUrl, layerName);
|
||||||
|
|
||||||
if (baseUrl.includes('/gwc/service/wms')) {
|
if (baseUrl.includes('/gwc/service/wms')) {
|
||||||
@@ -1027,7 +1031,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const validPoints = tracePoints.filter(p => {
|
const validPoints = tracePoints?.filter(p => {
|
||||||
const lng = Number(p.lng);
|
const lng = Number(p.lng);
|
||||||
const lat = Number(p.lat);
|
const lat = Number(p.lat);
|
||||||
return !isNaN(lng) && !isNaN(lat) && Math.abs(lng) < 180 && Math.abs(lat) < 90 && lng !== 0 && lat !== 0;
|
return !isNaN(lng) && !isNaN(lat) && Math.abs(lng) < 180 && Math.abs(lat) < 90 && lng !== 0 && lat !== 0;
|
||||||
@@ -1087,8 +1091,17 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
if (viewer) {
|
if (viewer) {
|
||||||
if (planLineRef.current) {
|
if (planLineRef.current) {
|
||||||
viewer.entities.remove(planLineRef.current);
|
viewer.entities.remove(planLineRef.current);
|
||||||
|
|
||||||
|
|
||||||
planLineRef.current = null;
|
planLineRef.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (polygonRef.current) {
|
||||||
|
viewer.entities.remove(polygonRef.current);
|
||||||
|
|
||||||
|
|
||||||
|
polygonRef.current = null;
|
||||||
|
}
|
||||||
viewer.scene.requestRender();
|
viewer.scene.requestRender();
|
||||||
}
|
}
|
||||||
prevIfClearPlanLine.current = ifClearPlanLine;
|
prevIfClearPlanLine.current = ifClearPlanLine;
|
||||||
@@ -1397,7 +1410,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const picked = viewer.scene.pick(movement.endPosition);
|
const picked = viewer.scene.pick(movement.endPosition);
|
||||||
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
|
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
|
||||||
const robot = picked.id.properties.robot.getValue();
|
const robot = picked.id.properties.robot.getValue();
|
||||||
showRobotTooltip(tooltipRef.current, robot, movement.endPosition);
|
showRobotTooltip(tooltipRef.current, robot, movement.endPosition, t);
|
||||||
} else {
|
} else {
|
||||||
tooltipRef.current.style.display = "none";
|
tooltipRef.current.style.display = "none";
|
||||||
}
|
}
|
||||||
@@ -1599,7 +1612,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
|
|
||||||
// 如果有航向角,设置旋转
|
// 如果有航向角,设置旋转
|
||||||
let rotation = 0;
|
let rotation = 0;
|
||||||
console.log('realtimePosition.heading:', realtimePosition.heading);
|
|
||||||
|
|
||||||
|
|
||||||
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user