无人机管理后台前端(已迁走)
张含笑
2025-10-29 d95ca015de7641aba381e1c61de9dbdada085d4e
feat:清除编辑地图数据
2 files modified
54 ■■■■■ changed files
src/views/layerManagement/components/rightEdit.vue 5 ●●●● patch | view | raw | blame | history
src/views/layerManagement/index.vue 49 ●●●●● patch | view | raw | blame | history
src/views/layerManagement/components/rightEdit.vue
@@ -58,6 +58,7 @@
</template>
<script setup>
const emit = defineEmits([ 'callParentMethod']);
const layerParams = inject('layerParams');
const formData = ref({
  folder_id: '',
@@ -68,7 +69,7 @@
  altitude: '',
  control_start_time: '',
  control_end_time: '',
  geo_data: '{"type":"LineString","coordinates":[[113.30,23.15],[113.31,23.16],[113.32,23.15]]}',
  geo_data: '',
});
const detailData = ref(null)
detailData.value = layerParams.value.editDetailData
@@ -80,10 +81,12 @@
const cancelHandel = () => {
  layerParams.value.addNest = false;
  layerParams.value.editNest = false;
   emit('callParentMethod');
};
const submitHandle = () => {
  layerParams.value.addNest = false;
  layerParams.value.editNest = false;
   emit('callParentMethod');
};
</script>
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);