feat(map): 优化地图组件及接口请求性能

- 新增获取码头人员车辆统计接口getScreenPortPersonVehicleStat
- 中心工具组件引入数据加载及界面loading状态展示
- 中心工具统计数据显示人数及车辆数动态渲染
- 所有分页请求pageSize由9999调整为99,减少数据加载压力
- useInitMap、useMapMethods及usePointClickEvent中getViewer调用优化,避免多次重复调用
- 统一使用viewer变量缓存getViewer返回值,代码结构更清晰易维护
master
LiuJiaNan 2026-08-03 10:07:50 +08:00
parent f2109d6e80
commit 37e94a178c
25 changed files with 108 additions and 77 deletions

View File

@ -208,3 +208,7 @@ export const getScreenRelatedCorpStatistics = declareRequest(
"getScreenRelatedCorpStatisticsLoading", "getScreenRelatedCorpStatisticsLoading",
"Post > @/xgfManager/project/relatedCorpStatistics", "Post > @/xgfManager/project/relatedCorpStatistics",
); );
export const getScreenPortPersonVehicleStat = declareRequest(
"getScreenPortPersonVehicleStatLoading",
"Get > /personnelPosition/bi/personLocation/portPersonVehicleStat",
);

View File

@ -1,5 +1,7 @@
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Spin } from "antd";
import { AnimatePresence, motion } from "motion/react"; import { AnimatePresence, motion } from "motion/react";
import { useContext } from "react"; import { useContext, useEffect, useState } from "react";
import statisticsTitleImg from "~/assets/images/map_bi/center_utils/statistics_title.png"; import statisticsTitleImg from "~/assets/images/map_bi/center_utils/statistics_title.png";
import guangImg from "~/assets/images/map_bi/center_utils/tabguang.png"; import guangImg from "~/assets/images/map_bi/center_utils/tabguang.png";
import tabLeftImg from "~/assets/images/map_bi/center_utils/tableft.png"; import tabLeftImg from "~/assets/images/map_bi/center_utils/tableft.png";
@ -8,6 +10,7 @@ import tabMidImg from "~/assets/images/map_bi/center_utils/tabmid.png";
import tabMidOnImg from "~/assets/images/map_bi/center_utils/tabmid_on.png"; import tabMidOnImg from "~/assets/images/map_bi/center_utils/tabmid_on.png";
import tabRightImg from "~/assets/images/map_bi/center_utils/tabright.png"; import tabRightImg from "~/assets/images/map_bi/center_utils/tabright.png";
import tabRightOnImg from "~/assets/images/map_bi/center_utils/tabright_on.png"; import tabRightOnImg from "~/assets/images/map_bi/center_utils/tabright_on.png";
import { NS_BI_STATISTICS } from "~/enumerate/namespace";
import { Context } from "~/pages/Container/Map/js/context"; import { Context } from "~/pages/Container/Map/js/context";
import "./index.less"; import "./index.less";
@ -42,9 +45,11 @@ const statisticAnimation = {
}, },
}; };
function CenterUtils() { function CenterUtils(props) {
const { currentPort, currentBranchOffice, pureMap, mapMethods, actions, portArea } = useContext(Context); const { currentPort, currentBranchOffice, pureMap, mapMethods, actions, portArea } = useContext(Context);
const [data, setData] = useState([]);
const list = [ const list = [
{ label: "秦皇岛西", portArea: 3 }, { label: "秦皇岛西", portArea: 3 },
{ label: "秦皇岛港区", portArea: "" }, { label: "秦皇岛港区", portArea: "" },
@ -62,6 +67,16 @@ function CenterUtils() {
actions.resetBottomUtils(); actions.resetBottomUtils();
}; };
useEffect(() => {
const loadData = async () => {
if (!isVisible)
return;
const { data } = await props.getScreenPortPersonVehicleStat();
setData(data || []);
};
loadData();
}, [isVisible]);
return ( return (
<div className="map_content_center_options_container"> <div className="map_content_center_options_container">
<AnimatePresence> <AnimatePresence>
@ -87,34 +102,27 @@ function CenterUtils() {
</div> </div>
))} ))}
</div> </div>
<Spin spinning={props.biStatistics.getScreenPortPersonVehicleStatLoading}>
<div className="statistics"> <div className="statistics">
<AnimatePresence> {
{["", 3].includes(portArea) && ( data.map((item, index) => (
<motion.div key="west" {...statisticAnimation}> <AnimatePresence key={index}>
{["", item.portArea].includes(portArea) && (
<motion.div key={item.portArea} {...statisticAnimation}>
<div className="statistic"> <div className="statistic">
<div className="title" style={{ backgroundImage: `url(${statisticsTitleImg})` }}>西港区</div> <div className="title" style={{ backgroundImage: `url(${statisticsTitleImg})` }}>{item.portName}</div>
<div className="info"> <div className="info">
<div className="value">人数33</div> <div className="value">{`人数:${item.onlinePersonCount}`}</div>
<div className="value">车辆33</div> <div className="value">{`车辆:${item.onlineVehicleCount}`}</div>
</div>
</div>
</motion.div>
)}
</AnimatePresence>
<AnimatePresence>
{["", 2].includes(portArea) && (
<motion.div key="east" {...statisticAnimation}>
<div className="statistic">
<div className="title" style={{ backgroundImage: `url(${statisticsTitleImg})` }}>东港区</div>
<div className="info">
<div className="value">人数33</div>
<div className="value">车辆33</div>
</div> </div>
</div> </div>
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence>
))
}
</div> </div>
</Spin>
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence>
@ -122,4 +130,4 @@ function CenterUtils() {
); );
} }
export default CenterUtils; export default Connect([NS_BI_STATISTICS], true)(CenterUtils);

View File

@ -15,7 +15,7 @@ function RectificationPanel(props) {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getHiddenStatisticsByPortArea({ const { data } = await props.getHiddenStatisticsByPortArea({
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -26,7 +26,7 @@ function WeatherPanel(props) {
const { data } = await props.getEventReportListUnfinished({ const { data } = await props.getEventReportListUnfinished({
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setEmergencyList(data || []); setEmergencyList(data || []);
}; };

View File

@ -15,7 +15,7 @@ function AlarmPanel(props) {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getAlarmRecordScreenIotDeviceAlarmPage({ const { data } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -15,7 +15,7 @@ function PartnerPanel(props) {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getXgfStatisticsListCorpStatistics({ const { data } = await props.getXgfStatisticsListCorpStatistics({
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -33,7 +33,7 @@ function Camera(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}), }),
]); ]);
setLevelList(dictionaryData); setLevelList(dictionaryData);

View File

@ -20,7 +20,7 @@ function AreaAlarmPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -36,7 +36,7 @@ function VideoPatrolPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
const videos = formatVideoList(data || []); const videos = formatVideoList(data || []);
setVideoList(videos); setVideoList(videos);

View File

@ -21,7 +21,7 @@ function GateApplicationPanel(props) {
setIsVisible(false); setIsVisible(false);
const { data } = await props[activeIndex === 1 ? "getPrimeportClosedAreaCarApplyScreenList" : "getPrimeportClosedAreaPersonApplyScreenList"]({ const { data } = await props[activeIndex === 1 ? "getPrimeportClosedAreaCarApplyScreenList" : "getPrimeportClosedAreaPersonApplyScreenList"]({
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
}); });

View File

@ -17,7 +17,7 @@ function AlarmHandlingPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getAlarmRecordList({ portArea, corpinfoId: currentBranchOffice }); const { data } = await props.getAlarmRecordList({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 99 });
setData(data || []); setData(data || []);
}; };

View File

@ -15,7 +15,7 @@ function PersonnelLocationPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getPersonLocationPositioning({ portArea, corpinfoId: currentBranchOffice }); const { data } = await props.getPersonLocationPositioning({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 99 });
setData(data || []); setData(data || []);
}; };

View File

@ -14,7 +14,7 @@ function DepartmentWorkPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getScreenWorkPage({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999 }); const { data } = await props.getScreenWorkPage({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 99 });
setData(data); setData(data);
}; };
loadData(); loadData();

View File

@ -20,7 +20,7 @@ function FireAlarmRecordPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -16,7 +16,7 @@ function FireInspectionRecordPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getScreenFireCheckList({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999 }); const { data } = await props.getScreenFireCheckList({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 99 });
setData(data); setData(data);
}; };
loadData(); loadData();

View File

@ -18,7 +18,7 @@ function VolunteerFireTeamPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -163,7 +163,7 @@ function ContractProjectPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
initEcharts(data || []); initEcharts(data || []);
}; };

View File

@ -27,7 +27,7 @@ function MobileMonitoringPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
if (data?.length) { if (data?.length) {
loadPlayUrl(data[Math.floor(randoms(0, data.length - 1))].cameraNumber); loadPlayUrl(data[Math.floor(randoms(0, data.length - 1))].cameraNumber);

View File

@ -24,7 +24,7 @@ function PersonnelStatsPanel(props) {
portArea, portArea,
enterpriseType, enterpriseType,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
setIsVisible(true); setIsVisible(true);

View File

@ -15,7 +15,7 @@ function AlarmListPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getAlarmRecordList({ portArea }); const { data } = await props.getAlarmRecordList({ portArea, pageIndex: 1, pageSize: 99 });
setData(data || []); setData(data || []);
}; };

View File

@ -19,7 +19,7 @@ function WorkRecordPanel(props) {
const { data } = await props.getEightWorkInfoScreenWorkRecord({ const { data } = await props.getEightWorkInfoScreenWorkRecord({
portArea, portArea,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
}; };

View File

@ -21,7 +21,7 @@ function FireDeviceListPanel(props) {
portArea, portArea,
...queryParams, ...queryParams,
pageIndex: 1, pageIndex: 1,
pageSize: 9999, pageSize: 99,
}); });
setData(data || []); setData(data || []);
setIsVisible(true); setIsVisible(true);

View File

@ -54,11 +54,12 @@ export default function useInitMap(options) {
// 注册点击事件 // 注册点击事件
const registerClickEvent = () => { const registerClickEvent = () => {
getViewer().cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK); const viewer = getViewer();
getViewer().cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
const screenSpaceEventHandler = new Cesium.ScreenSpaceEventHandler(getViewer().scene.canvas); viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
const screenSpaceEventHandler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
screenSpaceEventHandler.setInputAction((movement) => { screenSpaceEventHandler.setInputAction((movement) => {
const pick = getViewer().scene.pick(movement.position); const pick = viewer.scene.pick(movement.position);
if (Cesium.defined(pick) && pick.id?.id) { if (Cesium.defined(pick) && pick.id?.id) {
pointClickEventRef.current.pointClickEvent(pick.id); pointClickEventRef.current.pointClickEvent(pick.id);
} }
@ -98,8 +99,9 @@ export default function useInitMap(options) {
show: true, show: true,
}), }),
}); });
const viewer = getViewer();
// 调整 Cesium 默认相机操作:左键旋转地图,右键调整俯仰角,实现从平面俯视到立体视角的切换。 // 调整 Cesium 默认相机操作:左键旋转地图,右键调整俯仰角,实现从平面俯视到立体视角的切换。
const cameraController = getViewer().scene.screenSpaceCameraController; const cameraController = viewer.scene.screenSpaceCameraController;
cameraController.rotateEventTypes = Cesium.CameraEventType.LEFT_DRAG; cameraController.rotateEventTypes = Cesium.CameraEventType.LEFT_DRAG;
cameraController.tiltEventTypes = [ cameraController.tiltEventTypes = [
Cesium.CameraEventType.RIGHT_DRAG, Cesium.CameraEventType.RIGHT_DRAG,
@ -110,8 +112,8 @@ export default function useInitMap(options) {
Cesium.CameraEventType.WHEEL, Cesium.CameraEventType.WHEEL,
Cesium.CameraEventType.PINCH, Cesium.CameraEventType.PINCH,
]; ];
getViewer()._cesiumWidget._creditContainer.style.display = "none"; // 隐藏cesium ion viewer._cesiumWidget._creditContainer.style.display = "none"; // 隐藏cesium ion
getViewer().imageryLayers.addImageryProvider( viewer.imageryLayers.addImageryProvider(
new Cesium.WebMapTileServiceImageryProvider({ new Cesium.WebMapTileServiceImageryProvider({
// 影像注记 // 影像注记
url: url:
@ -127,7 +129,7 @@ export default function useInitMap(options) {
); );
initObliquePhotography(); initObliquePhotography();
registerClickEvent(); registerClickEvent();
return { mapMethods: mapMethods.current, viewer: getViewer() }; return { mapMethods: mapMethods.current, viewer };
}; };
return { return {

View File

@ -99,27 +99,31 @@ export default function useMapMethods(viewerRef, request) {
// 设置中心点 // 设置中心点
const flyTo = ({ longitude, latitude, height } = defineCenterPoint) => { const flyTo = ({ longitude, latitude, height } = defineCenterPoint) => {
getViewer().camera.flyTo({ destination: getPosition(longitude, latitude, height), duration: 2 }); const viewer = getViewer();
viewer.camera.flyTo({ destination: getPosition(longitude, latitude, height), duration: 2 });
previousCenterPointRef.current = { ...currentCenterPointRef.current }; previousCenterPointRef.current = { ...currentCenterPointRef.current };
currentCenterPointRef.current = { longitude, latitude, height }; currentCenterPointRef.current = { longitude, latitude, height };
}; };
// 返回当前中心点 // 返回当前中心点
const returnCurrentCenterPoint = () => { const returnCurrentCenterPoint = () => {
const viewer = getViewer();
const { longitude, latitude, height } = currentCenterPointRef.current; const { longitude, latitude, height } = currentCenterPointRef.current;
getViewer().camera.flyTo({ destination: getPosition(longitude, latitude, height), duration: 2 }); viewer.camera.flyTo({ destination: getPosition(longitude, latitude, height), duration: 2 });
}; };
// 返回上一次中心点 // 返回上一次中心点
const returnPreviousCenterPoint = () => { const returnPreviousCenterPoint = () => {
const viewer = getViewer();
const { longitude, latitude, height } = previousCenterPointRef.current; const { longitude, latitude, height } = previousCenterPointRef.current;
getViewer().camera.flyTo({ destination: getPosition(longitude, latitude, height), duration: 2 }); viewer.camera.flyTo({ destination: getPosition(longitude, latitude, height), duration: 2 });
currentCenterPointRef.current = { longitude, latitude, height }; currentCenterPointRef.current = { longitude, latitude, height };
}; };
// 切换场景模式 // 切换场景模式
const changeSceneMode = (type = "3d") => { const changeSceneMode = (type = "3d") => {
getViewer().scene.mode = { "2d": Cesium.SceneMode.COLUMBUS_VIEW, "3d": Cesium.SceneMode.SCENE3D }[type]; const viewer = getViewer();
viewer.scene.mode = { "2d": Cesium.SceneMode.COLUMBUS_VIEW, "3d": Cesium.SceneMode.SCENE3D }[type];
}; };
// 添加港口点 // 添加港口点
@ -143,7 +147,8 @@ export default function useMapMethods(viewerRef, request) {
// 移除港口点 // 移除港口点
const removePortPoint = () => { const removePortPoint = () => {
removeEntityCollection(getViewer(), "portEntityCollectionMerged"); const viewer = getViewer();
removeEntityCollection(viewer, "portEntityCollectionMerged");
}; };
// 添加分公司点 // 添加分公司点
@ -183,7 +188,8 @@ export default function useMapMethods(viewerRef, request) {
// 删除分公司点 // 删除分公司点
const removeBranchOfficePoint = () => { const removeBranchOfficePoint = () => {
removeEntityCollection(getViewer(), "branchOfficeEntityCollectionMerged"); const viewer = getViewer();
removeEntityCollection(viewer, "branchOfficeEntityCollectionMerged");
}; };
// 添加四色图 // 添加四色图
@ -197,10 +203,11 @@ export default function useMapMethods(viewerRef, request) {
if (!edgeMap[id]) if (!edgeMap[id])
return; return;
const viewer = getViewer();
mitt.emit(changeCoverMaskVisibleMittKey, true); mitt.emit(changeCoverMaskVisibleMittKey, true);
const currentEdge = edgeMap[id](); const currentEdge = edgeMap[id]();
const entityCollection = createEntityCollection("fourColorDiagramEntityCollection"); const entityCollection = createEntityCollection("fourColorDiagramEntityCollection");
getViewer().dataSources.add(entityCollection); viewer.dataSources.add(entityCollection);
// 先收集需要渲染的数据 // 先收集需要渲染的数据
const itemsToRender = []; const itemsToRender = [];
@ -244,7 +251,8 @@ export default function useMapMethods(viewerRef, request) {
// 删除四色图 // 删除四色图
const removeFourColorDiagram = () => { const removeFourColorDiagram = () => {
removeEntityCollection(getViewer(), "fourColorDiagramEntityCollection"); const viewer = getViewer();
removeEntityCollection(viewer, "fourColorDiagramEntityCollection");
}; };
// 添加墙 // 添加墙
@ -294,7 +302,8 @@ export default function useMapMethods(viewerRef, request) {
// 删除墙 // 删除墙
const removeWall = () => { const removeWall = () => {
removeEntityCollection(getViewer(), "wallEntityCollection"); const viewer = getViewer();
removeEntityCollection(viewer, "wallEntityCollection");
}; };
// 点位聚合 // 点位聚合
@ -406,12 +415,14 @@ export default function useMapMethods(viewerRef, request) {
// 删除点位 // 删除点位
const removeMarkPoint = (markType) => { const removeMarkPoint = (markType) => {
removeEntityCollection(getViewer(), `markEntityCollectionMerged${markType ? `_${markType}` : ""}`); const viewer = getViewer();
removeEntityCollection(viewer, `markEntityCollectionMerged${markType ? `_${markType}` : ""}`);
}; };
// 查询新轨迹前先移除旧轨迹,确保地图上始终只展示当前筛选结果。 // 查询新轨迹前先移除旧轨迹,确保地图上始终只展示当前筛选结果。
const removePeopleTrajectory = () => { const removePeopleTrajectory = () => {
getViewer().entities.removeById("peopleTrajectoryEntity"); const viewer = getViewer();
viewer.entities.removeById("peopleTrajectoryEntity");
}; };
// 将接口返回的经纬高点位绘制为动态轨迹线,少于两个点时不创建无意义的线段。 // 将接口返回的经纬高点位绘制为动态轨迹线,少于两个点时不创建无意义的线段。
@ -420,13 +431,14 @@ export default function useMapMethods(viewerRef, request) {
if (points.length < 2) if (points.length < 2)
return; return;
const viewer = getViewer();
const coordinates = points.flatMap(point => [point.lon, point.lat, point.alt || 0]); const coordinates = points.flatMap(point => [point.lon, point.lat, point.alt || 0]);
getViewer().entities.add({ viewer.entities.add({
id: "peopleTrajectoryEntity", id: "peopleTrajectoryEntity",
polyline: { polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights(coordinates), positions: Cesium.Cartesian3.fromDegreesArrayHeights(coordinates),
width: 5, width: 5,
material: new Cesium.TrajectoryPolylineTrailLinkMaterialProperty(getViewer()), material: new Cesium.TrajectoryPolylineTrailLinkMaterialProperty(viewer),
clampToGround: true, clampToGround: true,
}, },
}); });
@ -451,6 +463,7 @@ export default function useMapMethods(viewerRef, request) {
return; return;
if (!options.markType) if (!options.markType)
throw new Error("请传入markType扎点类型"); throw new Error("请传入markType扎点类型");
const viewer = getViewer();
const clonePoint = { ...point }; const clonePoint = { ...point };
point.property = new Cesium.SampledPositionProperty(); point.property = new Cesium.SampledPositionProperty();
// 下一条实时定位到达前保持最后有效位置,避免全局时钟前进后点位短暂消失。 // 下一条实时定位到达前保持最后有效位置,避免全局时钟前进后点位短暂消失。
@ -463,7 +476,7 @@ export default function useMapMethods(viewerRef, request) {
point.lastTime = start; point.lastTime = start;
point.lastIconType = point.icon_type; point.lastIconType = point.icon_type;
peopleId.current.push(point.id); peopleId.current.push(point.id);
getViewer().entities.add({ viewer.entities.add({
id: point.id, id: point.id,
name: point.name, name: point.name,
position: point.property, position: point.property,
@ -507,14 +520,16 @@ export default function useMapMethods(viewerRef, request) {
// 删除人员定位点 // 删除人员定位点
const removePeoplePoint = (id) => { const removePeoplePoint = (id) => {
getViewer().entities.removeById(id); const viewer = getViewer();
viewer.entities.removeById(id);
peopleId.current = peopleId.current.filter(item => item !== id); peopleId.current = peopleId.current.filter(item => item !== id);
}; };
// 删除所有人员定位点 // 删除所有人员定位点
const removePeoplePointAll = () => { const removePeoplePointAll = () => {
const viewer = getViewer();
peopleId.current.forEach((id) => { peopleId.current.forEach((id) => {
getViewer().entities.removeById(id); viewer.entities.removeById(id);
}); });
peopleId.current = []; peopleId.current = [];
peoplePositionStartTime.current = null; peoplePositionStartTime.current = null;

View File

@ -55,8 +55,9 @@ export default function usePointClickEvent(viewerRef, mapMethods) {
// 港口点位点击 // 港口点位点击
const clickPortPoint = (data) => { const clickPortPoint = (data) => {
const viewer = getViewer();
const position = getPosition(data.position.x, data.position.y); const position = getPosition(data.position.x, data.position.y);
popupRef.current = new PopupInfo(getViewer(), { popupRef.current = new PopupInfo(viewer, {
component: Port, component: Port,
position, position,
props: { props: {
@ -88,8 +89,9 @@ export default function usePointClickEvent(viewerRef, mapMethods) {
if (data.id === sessionStorage.getItem("mapCurrentBranchOfficeId")) if (data.id === sessionStorage.getItem("mapCurrentBranchOfficeId"))
return; return;
const viewer = getViewer();
const position = getPosition(data.longitude, data.latitude); const position = getPosition(data.longitude, data.latitude);
popupRef.current = new PopupInfo(getViewer(), { popupRef.current = new PopupInfo(viewer, {
component: BranchOffice, component: BranchOffice,
position, position,
props: { props: {