无人机管理后台前端(已迁走)
张含笑
2025-11-07 75dc6ecb2d0f9cff6a9c4cee4d2acc6ccba49ae3
feat:定位可视范围调整
1 files modified
45 ■■■■ changed files
src/views/layerManagement/index.vue 45 ●●●● patch | view | raw | blame | history
src/views/layerManagement/index.vue
@@ -64,7 +64,6 @@
const store = useStore();
const userInfo = computed(() => store.getters.userInfo);
const areaCode = userInfo.value?.detail?.areaCode || '';
// console.log('用户信息',areaCode);
// 红色警告交叉面提示窗
const isShowWaringTip = ref(false);
const activeName = ref('电子围栏');
@@ -139,31 +138,19 @@
    layerParams.value.folderOption = formattedFolderOption;
  });
};
// 编辑围栏区域
// const handleEdit = val => {
// console.log('编辑数据',val.geo_data);
//   viewer.entities.removeAll();
//   layerParams.value.editDetailData = val;
//   drawPolygonExample.editThePatch(true);
//   drawPolygonExample.drawTheArea(true);
//   const positions = parseGeoDataToPositions(val.geo_data, val.altitude);
//   if (positions.length < 3) return; // 少于3个点无法构成多边形
//   drawPolygonExample.initPolygon(viewer, positions, true);
// };
// 编辑围栏区域
const handleEdit = val => {
  viewer.entities.removeAll();
  layerParams.value.editDetailData = val;
  drawPolygonExample.editThePatch(true);
  drawPolygonExample.drawTheArea(true); 
  // 移除最后一个点
  let geoDataArr = JSON.parse(val.geo_data);
  if (geoDataArr.length > 0) {
    geoDataArr.pop();
  }
  const processedGeoData = JSON.stringify(geoDataArr);
  // 使用处理后的 geo_data 解析坐标
  //geo_data 解析坐标
  const positions = parseGeoDataToPositions(processedGeoData, val.altitude);
  if (positions.length < 3) return; // 少于3个点无法构成多边形
  drawPolygonExample.initPolygon(viewer, positions, true);
@@ -187,6 +174,8 @@
};
// 点击显示区域
const handleCoverDataUpdate = data => {
console.log('data',data);
  selectDataList.value = data;
  if (selectDataList.value.length > 0) {
    loadDataToMap(selectDataList.value);
@@ -201,13 +190,11 @@
  tbJwdList = [];
  dataList.forEach(item => {
    let positions = parseGeoDataToPositions(item.geo_data, item.altitude);
    // positions.push(positions[0]);
    if (positions.length < 3) {
      console.warn(`数据 ${item.name} 坐标点不足,无法绘制`);
      return;
    }
    tbJwdList.push(...positions);
    //  转换为 Cesium 所需的 [lng, lat, lng, lat, ...] 扁平数组格式
    let degreesArray = [];
    positions.forEach(pos => {
      degreesArray.push(pos.lng, pos.lat, pos.height);
@@ -239,22 +226,18 @@
  focusOnAllFeatures();
  viewInstance.value?.addLeftClickEvent(null, handleFenceClick);
};
//计算所有图斑的包围球并定位
const focusOnAllFeatures = () => {
  if (tbJwdList.length === 0 || !viewer) return;
  // 转换所有经纬度坐标为Cartesian3
  const allPositions = tbJwdList.flatMap(pos =>
    Cesium.Cartesian3.fromDegrees(pos.lng, pos.lat, pos.height || 0)
  );
  if (allPositions.length === 0) return;
  const boundingSphere = Cesium.BoundingSphere.fromPoints(allPositions);
  viewer.camera.flyToBoundingSphere(boundingSphere, {
    duration: 0, // 飞行时间(秒)
    offset: new Cesium.HeadingPitchRange(
      Cesium.Math.toRadians(0), // 方向角
      Cesium.Math.toRadians(-90) // 俯仰角
    ),
  const positionsData = tbJwdList.map(pos => [
    pos.lng,
    pos.lat,
    pos.height || 0
  ]);
  flyVisual({
    positionsData,
    viewer,
    multiple: 13, // 缩放倍数
    pitch: -90
  });
};
// 区域点击显示详细信息
@@ -291,8 +274,6 @@
let viewer = null;
const viewInstance = shallowRef(null);
const homeViewer = shallowRef(null);
// 初始化绘制工具实例
const drawPolygonExample = new DrawPolygon();
// 地图初始化
const initMap = () => {