wangjuncheng
2025-07-08 f373e0c0797e1800bf066fdfbb748bb9242230f6
src/components/tools/LayerTree.vue
@@ -14,13 +14,23 @@
<script setup>
import { ref, onMounted, watch, nextTick, onUnmounted, watchEffect } from "vue";
import { createPoint, removeEntities, addTileset } from "@/utils/map";
import {
  createPoint,
  removeEntities,
  addTileset,
  clearAllPoints,
} from "@/utils/map";
import { deviceDictList, getDictName } from "@/constant/dict.js";
import { useRoute } from "vue-router";
import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area";
import {
  loadAreaPolygon,
  convertToGeoJson,
  clearAreaPolygon,
} from "@/utils/area";
import { checkedKeys } from "@/store/index";
import { getDuanMainData } from "@/api/index.js";
import { useSimStore } from "@/store/simulation";
import { getSafePoint } from "@/api/hpApi";
const simStore = useSimStore();
const route = useRoute();
@@ -233,9 +243,7 @@
  const list = treeMap.get(layerName);
  if (list && Array.isArray(list)) {
    list.forEach((entity) => {
      if (viewer.entities.contains(entity)) {
        viewer.entities.remove(entity);
      }
      clearAllPoints();
    });
  }
  treeMap.delete(layerName);
@@ -248,17 +256,14 @@
  if (simStore.DeviceShowSwitch) {
    const deviceList = simStore.devices
      .filter((item) => item.deviceName?.includes("孙胡沟"))
      .map((item) => {
        const entity = createPoint({
          ...item,
          type: getDictName(deviceDictList, item.dictDeviceType),
          name: item.deviceName.split("孙胡沟")[1],
          id: item.deviceId,
          className: "device",
          showLabel: true,
        });
        entity.show = true;
        return entity;
      .map(async (item) => {
        const entity = viewer.entities.getById(item.deviceId);
        item.type = getDictName(deviceDictList, item.dictDeviceType);
        item.name = item.deviceName.split("孙胡沟")[1];
        item.id = item.deviceId;
        item.className = "device";
        item.showLabel = true;
        await createPoint(item);
      });
    if (deviceList.length) {
@@ -274,18 +279,16 @@
  if (simStore.DangerShowSwitch) {
    const dangerPoints = simStore.DangerPoint.filter((item) =>
      item.position?.includes("孙胡沟")
    ).map((item) => {
      const entity = createPoint({
        id: item.hdId,
        name: item.hdName,
        latitude: item.lat,
        longitude: item.lon,
        showBillboard: true,
        type: item.disasterType,
        className: "district",
      });
      entity.show = true;
      return entity;
    ).map(async (item) => {
      const entity = viewer.entities.getById(item.hdId);
      item.id = item.hdId;
      item.name = item.hdName;
      item.latitude = item.lat;
      item.longitude = item.lon;
      item.showBillboard = true;
      item.type = item.disasterType;
      item.className = "district";
      await createPoint(item);
    });
    if (dangerPoints.length) {
@@ -319,9 +322,13 @@
 * 添加避险场所数据
 */
function addTetrahedron() {
  loadAreaPolygon("/json/emergency_area.geojson", true).then((entities) => {
    entities.forEach((entity) => (entity.show = false));
    treeMap.set("避险场所", entities);
  getSafePoint().then((res) => {
    const geoJsonData = convertToGeoJson(res.data); // 转换为 GeoJSON
    // 加载 GeoJSON 数据到地图
    loadAreaPolygon(geoJsonData, true).then((entities) => {
      entities.forEach((entity) => (entity.show = false));
      treeMap.set("避险场所", entities);
    });
  });
}
@@ -350,6 +357,7 @@
    const defaultKeys = [...defaultSelectedKeys.value];
    const checkedKeys =
      {
        // 页面默认勾选显示在此处
        "/yhgl": [...defaultKeys, "孙胡沟隐患点"],
        "/zhjc": [...defaultKeys, "综合监测设备信息"],
        // "/mnfz": [...defaultKeys, "孙胡沟断面"],