无人机管理后台前端(已迁走)
张含笑
2025-10-29 d95ca015de7641aba381e1c61de9dbdada085d4e
src/views/layerManagement/index.vue
@@ -16,7 +16,10 @@
          @update:deitData="handleEdit"
          :activeName="activeName"
        ></leftList>
        <rightEdit v-if="layerParams.addNest || layerParams.editNest"></rightEdit>
        <rightEdit
          v-if="layerParams.addNest || layerParams.editNest"
          @callParentMethod="parentMethod"
        ></rightEdit>
      </div>
    </div>
  </basic-container>
@@ -35,7 +38,7 @@
const activeName = ref('电子围栏');
const activeType = ref('0');
// 当前面位置信息
let curPolygonPosition = []
let curPolygonPosition = [];
const tabData = ref([
  {
    name: '电子围栏',
@@ -52,10 +55,10 @@
]);
const layerParams = ref({
  addNest: false,
  editNest:false,
  editDetailData:null,
  total_count:0,
  total_area:0,
  editNest: false,
  editDetailData: null,
  total_count: 0,
  total_area: 0,
});
provide('layerParams', layerParams);
const handleClick = tab => {
@@ -97,11 +100,15 @@
// 编辑区域
const handleEdit = val => {
  console.log('编辑数据', val);
  layerParams.value.editDetailData = val
  layerParams.value.editDetailData = val;
  drawPolygonExample.editThePatch(true);
  const positions = parseGeoDataToPositions(val.geo_data, val.altitude);
  if (positions.length < 3) return; // 少于3个点无法构成多边形
  drawPolygonExample.initPolygon(viewer, positions, true);
};
// 清除地图数据
const parentMethod = () => {
drawPolygonExample.delPolygon()
};
// 点击显示区域
const handleCoverDataUpdate = data => {
@@ -231,23 +238,23 @@
// 编辑/绘制
const loadPlanarRoute = async (positions = null, save = false) => {
  if (positions){
  if (positions) {
    curPolygonPosition = positions.map(item => {
         let cartographic = Cesium.Cartographic.fromCartesian(item)
         let lng = Cesium.Math.toDegrees(cartographic.longitude) // 经度
         let lat = Cesium.Math.toDegrees(cartographic.latitude) // 纬度
         let height = Cesium.Math.toDegrees(cartographic.height) //高度
         return {
            lng: _.round(lng, 6),
            lat: _.round(lat, 6),
            height: _.round(height, 6),
         }
      })
      let cartographic = Cesium.Cartographic.fromCartesian(item);
      let lng = Cesium.Math.toDegrees(cartographic.longitude); // 经度
      let lat = Cesium.Math.toDegrees(cartographic.latitude); // 纬度
      let height = Cesium.Math.toDegrees(cartographic.height); //高度
      return {
        lng: _.round(lng, 6),
        lat: _.round(lat, 6),
        height: _.round(height, 6),
      };
    });
  }
  let polygon = curPolygonPosition.map(item => [item?.lng, item?.lat])
   polygon.push([curPolygonPosition[0]?.lng, curPolygonPosition[0]?.lat])
  let polygon = curPolygonPosition.map(item => [item?.lng, item?.lat]);
  polygon.push([curPolygonPosition[0]?.lng, curPolygonPosition[0]?.lat]);
  console.log('绘制的多边形顶点坐标(Cartesian3):', polygon);
  console.log('转换后的经纬度坐标:', curPolygonPosition);
};
const throttleLoadPlanarRoute = throttle(loadPlanarRoute, 200);