riku
2025-09-03 b2392458ebf42594b9fc5390fda40d7a0a12f923
src/components/map/MapScene.vue
@@ -42,6 +42,8 @@
import sceneInfoApi from '@/api/sceneInfoApi';
import marks from '@/utils/map/marks';
import MapUtil from '@/utils/map/util';
import { useToolboxStore } from '@/stores/toolbox';
import { mapStores } from 'pinia';
const lableMarkMap = new Map();
@@ -55,6 +57,18 @@
      options: sceneTypes(),
      sceneMap: new Map()
    };
  },
  computed: {
    ...mapStores(useToolboxStore)
  },
  watch: {
    // 当切换区县时,清空所有选项
    districtCode(nV, oV) {
      if (nV != oV) {
        this.toolboxStore.selectedDistrict = nV;
        this.handelCheckAllChange(false);
      }
    }
  },
  methods: {
    fetchScene(sceneType) {
@@ -84,13 +98,19 @@
      // 根据选项,将未打开的图层开启
      types.forEach((t) => {
        if (!lableMarkMap.has(t)) {
        const key = this.districtCode + t;
        if (!lableMarkMap.has(key)) {
          this.fetchScene(t).then((res) => {
            const layer = marks.createLabelMarks(sceneIcon(t), res);
            lableMarkMap.set(t, { show: true, layer });
            const layer = marks.createLabelMarks(
              sceneIcon(t),
              res,
              false,
              true
            );
            lableMarkMap.set(key, { show: true, layer });
          });
        } else {
          const m = lableMarkMap.get(t);
          const m = lableMarkMap.get(key);
          if (!m.show) {
            MapUtil.addViews(m.layer);
            m.show = true;
@@ -100,7 +120,7 @@
      // 根据选项,将开启中的未选中图层关闭
      for (const [key, value] of lableMarkMap) {
        if (!types.includes(key)) {
        if (!types.map((t) => this.districtCode + t).includes(key)) {
          if (value.show) {
            MapUtil.removeViews(value.layer);
            value.show = false;