forked from drone/command-center-dashboard

chenyao
2025-04-03 9f55452e21a84c5c46528a0de51ccd7796643470
src/views/Home/useMapAggregation/useMapAggregation.js
File was renamed from src/views/Home/useUavHome/useUavHome.js
@@ -4,8 +4,8 @@
import eventImg from '@/assets/images/home/useEventOperate/event.png';
import DevicePopUpBox from '@/views/Home/useUavHome/DevicePopUpBox.vue';
import EventPopUpBox from '@/views/Home/useEventOperate/EventPopUpBox.vue';
import DevicePopUpBox from '@/views/Home/useMapAggregation/DevicePopUpBox.vue';
import EventPopUpBox from '@/views/Home/useMapAggregation/EventPopUpBox.vue';
import { render } from 'vue';
import { useStore } from 'vuex';
@@ -16,7 +16,7 @@
/**
 * 机巢聚合功能
 */
export const useUavHome = type => {
export const useMapAggregation = type => {
  const { flyTo } = cesiumOperation();
  const singleImg = type === 'device' ? uavImg : eventImg;
@@ -117,22 +117,22 @@
  function getMapEventCount(areaCode) {
    return getMapEvents({ areaCode }).then(res => {
      return processChildren(res?.data?.data?.childrens || []);
    });
  }
  function getEventDetailsFun(areaCode){
    return getEventDetails({areaCode}).then(res => {
      console.log(res.data.data,'getEventDetailsFun');
      const resData= res?.data?.data
      if (resData?.data){
        eventList = resData?.data
        return []
      }
      return processChildren(resData?.childrens);
    });
  }
  const findFun = (featItem, numItem) => Number(featItem.region_code.slice(0, 6)) === numItem.properties.adcode;
  const { VITE_APP_BASE } = import.meta.env;
  const defaultDir = `${VITE_APP_BASE}public/geoJson/100000/`;
  const { VITE_APP_BASE,VITE_APP_ENV } = import.meta.env;
  const defaultDir =  `${VITE_APP_BASE}${VITE_APP_ENV === 'development' ? 'public/' : ''}geoJson/100000/`;
  const getFiler = async url => {
    const gJson = await import(/* @vite-ignore */ url);
    return JSON.parse(JSON.stringify(gJson));
    const res = await fetch(url);
    return  await res.json()
  };
  const getOutLine = async (jsonPathPre, hierarchy) => {
    const parentGJson = await getFiler(`${defaultDir}${jsonPathPre}/index.json`);
@@ -150,6 +150,7 @@
  };
  const initMapData = async areaCode => {
    eventList = []
    if (!areaCode) return;
    const list = type === 'device' ? await getDeviceCount(areaCode) : await getMapEventCount(areaCode);
    const splashedList = type === 'device'
@@ -164,8 +165,9 @@
    scalingJudgment[0].gJson = null;
    scalingJudgment[0].splashedList = splashedList;
    active = null;
    console.log(hierarchy);
    // 轮廓
    const outlineGJson = await getOutLine(jsonPathPre, hierarchy);
    scalingJudgment.forEach(item => item.show && (item.outline = outlineGJson));
    // 省
    if (hierarchy.length === 1) {
      const gJson1 = await getFiler(`${defaultDir}${jsonPath}/indexDistrict.json`);
@@ -200,9 +202,7 @@
      const center = outlineGJson.features[0].properties.center;
      flyTo({ longitude: center[0], latitude: center[1] }, 0, scalingJudgment[0].height);
    }
    // 轮廓
    const outlineGJson = await getOutLine(jsonPathPre, hierarchy);
    scalingJudgment.forEach(item => item.show && (item.outline = outlineGJson));
    determineScaling()
  };
  watch(