refactor(map): 清理人员定位相关代码并优化注释
parent
c1f9fd0169
commit
1f7fee828f
|
|
@ -63,7 +63,6 @@ const peopleImg = {
|
|||
red: people_red,
|
||||
yellow: people_yellow,
|
||||
}; // 人员定位颜色图片
|
||||
const peopleTrajectoryEntityId = "peopleTrajectoryEntity";
|
||||
|
||||
const Cesium = window.Cesium;
|
||||
|
||||
|
|
@ -92,8 +91,11 @@ export default function useMapMethods(viewerRef, request) {
|
|||
height: 900000,
|
||||
});
|
||||
|
||||
const peopleId = useRef([]); // 人员定位 ID 列表
|
||||
const peoplePositionStartTime = useRef(null); // 当前人员定位会话共用的采样起始时间
|
||||
// 人员定位 ID 列表
|
||||
const peopleId = useRef([]);
|
||||
|
||||
// 当前人员定位会话共用的采样起始时间
|
||||
const peoplePositionStartTime = useRef(null);
|
||||
|
||||
// 设置中心点
|
||||
const flyTo = ({ longitude, latitude, height } = defineCenterPoint) => {
|
||||
|
|
@ -413,7 +415,7 @@ export default function useMapMethods(viewerRef, request) {
|
|||
|
||||
// 查询新轨迹前先移除旧轨迹,确保地图上始终只展示当前筛选结果。
|
||||
const removePeopleTrajectory = () => {
|
||||
getViewer().entities.removeById(peopleTrajectoryEntityId);
|
||||
getViewer().entities.removeById("peopleTrajectoryEntity");
|
||||
};
|
||||
|
||||
// 将接口返回的经纬高点位绘制为动态轨迹线,少于两个点时不创建无意义的线段。
|
||||
|
|
@ -424,7 +426,7 @@ export default function useMapMethods(viewerRef, request) {
|
|||
|
||||
const coordinates = points.flatMap(point => [point.lon, point.lat, point.alt || 0]);
|
||||
getViewer().entities.add({
|
||||
id: peopleTrajectoryEntityId,
|
||||
id: "peopleTrajectoryEntity",
|
||||
polyline: {
|
||||
positions: Cesium.Cartesian3.fromDegreesArrayHeights(coordinates),
|
||||
width: 5,
|
||||
|
|
@ -446,6 +448,7 @@ export default function useMapMethods(viewerRef, request) {
|
|||
return start;
|
||||
};
|
||||
|
||||
// 添加人员定位点
|
||||
const addPeoplePoint = async (point, options) => {
|
||||
const image = peopleImg[point.icon_type];
|
||||
if (!image)
|
||||
|
|
@ -478,6 +481,7 @@ export default function useMapMethods(viewerRef, request) {
|
|||
});
|
||||
};
|
||||
|
||||
// 更新人员定位点
|
||||
const updatePeoplePoint = async (point) => {
|
||||
const viewer = getViewer();
|
||||
if (viewer.clock.shouldAnimate === false) {
|
||||
|
|
@ -505,11 +509,13 @@ export default function useMapMethods(viewerRef, request) {
|
|||
point.lastTime = nextTime;
|
||||
};
|
||||
|
||||
// 删除人员定位点
|
||||
const removePeoplePoint = (id) => {
|
||||
getViewer().entities.removeById(id);
|
||||
peopleId.current = peopleId.current.filter(item => item !== id);
|
||||
};
|
||||
|
||||
// 删除所有人员定位点
|
||||
const removePeoplePointAll = () => {
|
||||
peopleId.current.forEach((id) => {
|
||||
getViewer().entities.removeById(id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue