This commit is contained in:
2025-12-11 22:03:40 +08:00
parent 65426b914f
commit c3be073cc7
4 changed files with 32 additions and 9 deletions

View File

@@ -127,6 +127,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { WebSocketClient, MockWebSocketDataGenerator } from './utils/websocket.js'
import droneImage from './assets/wrj.jpg'
import { getConfig } from ".//utils/request";
import gcoord from 'gcoord';
import DroneCtrl, {
UploadAreaReq
} from 'DroneCtrl';
@@ -331,7 +332,7 @@ const updateDroneMarker = (lng, lat, heading = 0) => {
}
// 将地图中心移动到无人机位置(可选,可以注释掉)
// map.setCenter([lng, lat])
map.setCenter([lng, lat])
}
// 检测点是否在多边形内(射线法)
@@ -850,7 +851,16 @@ const uploadFence = (fenceId) => {
}
if (pointsData) {
const points = pointsData.points;
const points = pointsData.points.map(point=> {
const wgsPoint = gcoord.transform(
point, // 原始坐标
gcoord.GCJ02, // 当前坐标系
gcoord.WGS84 // 目标坐标系
);
return wgsPoint;
});
console.log(points)
ctrl.UploadArea(new UploadAreaReq(points.map(point=>({
longitude: point[0],
latitude: point[1],
@@ -920,6 +930,7 @@ const removeFence = (fenceId) => {
console.error('删除围栏时出错:', error)
}
}
ctrl.ClearArea({});
// 从列表中移除
fences.value.splice(index, 1)
@@ -957,6 +968,7 @@ const clearAllFences = async () => {
type: 'warning',
}
)
await ctrl.ClearArea({});
// 先清除地图上的所有图形
const fencesToRemove = [...fences.value] // 创建副本避免遍历时修改数组