校园-江西科技师范大学-前端
shuishen
2023-12-14 e733164e1c779b3aef7245936b9daf7875bf791e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
window.urlParameterLayer = null;
window.divIcon = null;
 
const urlParameter = {
  state: {
    urlParameterData: {},
    // urlParameterLayer: null // 自定义标签图层
  },
  actions: {
    addurlParameterLayerIcon({ state, commit, dispatch }, val) {
      const list = val.list;
      if (val.clear) {
        //     window.urlParameterLayer.remove();
        window.urlParameterLayererLayer.clear();
      }
      for (const i in list) {
        const billboard = new global.DC.Billboard(
          new global.DC.Position(Number(list[i].jd), Number(list[i].wd), 0),
          "/changjing/img/icon/m-t.png"
        );
 
        const label = new global.DC.Label(
          new global.DC.Position(Number(list[i].jd), Number(list[i].wd), 0),
          list[i].name
        );
 
        label.setStyle({
          fillColor: global.DC.Color.RED,
          style: global.DC.Namespace.Cesium.LabelStyle.FILL_AND_OUTLINE,
          outlineColor: global.DC.Color.WHITE, // 边框颜色
          outlineWidth: 8, // 边框大小,
          font: "12px sans-serif",
          pixelOffset: { x: 0, y: -24 },
        });
 
        billboard.on(global.DC.MouseEventType.CLICK, (e) => {
          if (state.pinchFlag == true) {
            return;
          }
 
          const lntLat = [+list[i].jd, +list[i].wd];
          const d = {
            position: {},
            lntLat: lntLat,
            query: {
              introduce: "自定义标签",
              address: "",
              ...(list[i] || {}),
              lntLat: lntLat,
            },
            useJWD: true, // 仅使用经纬度
          };
          dispatch("setMobileWindows", d);
        });
 
        label.on(global.DC.MouseEventType.CLICK, (e) => {
          if (state.pinchFlag == true) {
            return;
          }
 
          const lntLat = [+list[i].jd, +list[i].wd];
          const d = {
            position: {},
            lntLat: lntLat,
            query: {
              introduce: "自定义标签",
              address: "",
              ...(list[i] || {}),
              lntLat: lntLat,
            },
            useJWD: true, // 仅使用经纬度
          };
          dispatch("setMobileWindows", d);
        });
 
        window.urlParameterLayer.addOverlay(billboard); // 加入图标
        window.urlParameterLayer.addOverlay(label);
      }
    },
  },
  mutations: {
    initurlParameterLayer(state, val) {
      if (!window.urlParameterLayer) {
        window.urlParameterLayer = new global.DC.VectorLayer(
          "urlParameterLayer"
        );
        global.viewer.addLayer(window.urlParameterLayer);
      }
    },
    set_urlParameterData(state, val) {
      state.urlParameterData = val;
    },
 
    clearurlParameterLayerIcon(state, val) {
      if (window.urlParameterLayer) {
        window.urlParameterLayer.clear();
      }
    },
  },
};
 
export default urlParameter;