wangjuncheng
7 天以前 bf0eb543e2deab8a1629dd2a46f8e1cd191531e1
src/views/mnfz.vue
@@ -142,28 +142,55 @@
  });
  dataSources.length = 0;
}
// 避险场所,绿色富文本
async function addTetrahedron(visible) {
  const emergencyAreaList = [];
  try {
    const res = await getSafePoint();
    let codesToFetch = [];
    const geoJsonData = convertToGeoJson(res.data);
    // 判断当前选择区域是否为“区”
    if (simStore.selectedScheme.areaName.includes("区")) {
      // 从 simStore.townCodeAll 中拿到该区下的所有乡镇 code
      const townList = simStore.townCodeAll[simStore.selectedScheme.areaName];
      // 假设 townList 是一个数组,里面每个元素有 .code 字段
      if (Array.isArray(townList)) {
        codesToFetch = townList.map((item) => item.code);
      } else {
        console.warn("未找到对应的乡镇列表");
        return;
      }
    } else {
      // 不是“区”,就使用默认 code
      codesToFetch = ["110116110218"];
    }
    // 并发请求所有 code 的避险点数据
    const allRes = await Promise.all(
      codesToFetch.map((code) => getSafePoint(code))
    );
    // 合并结果(假设每个 res.data 是一个数组)
    const allSafePoints = allRes.flatMap((res) => res.data);
    // 转换为 GeoJSON(如果每个 data 都需要单独处理)
    const geoJsonData = convertToGeoJson(allSafePoints);
    // 加载底层面片(多边形)
    const polygonEntities = await loadAreaPolygon(geoJsonData, true);
    emergencyAreaList.push(...polygonEntities);
    // 添加绿色富文本标注
    const textPromises = res.data.map(async (item) => {
    const textPromises = allSafePoints.map(async (item) => {
      const point = earthCtrl.factory.createRichTextPoint(
        "避险场所",
        [item.lon , item.lat , 540],
        [item.lon, item.lat, 540],
        {
          distanceDisplayCondition:
            new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000),
          fontColor: "#fff",
          fontColor: "#fff",
          fontSize: 20,
        },
        "0"
@@ -179,6 +206,7 @@
    console.error("加载避险场所失败:", error);
  }
}
// 删除避险场所的富文本实体
function removeEmergencyPoints() {
  const emergencyAreaList = treeMap.get("避险场所"); // 获取存储的避险场所实体列表