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