燕山石化溯源三维电子沙盘-【前端】-Web
WX
2023-08-30 4c846958fd4046b7a125224c759ae7ae0af673fa
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//服务加载配置文件
import server from "./server";
import menuData from "../menuData";
import menuTool from "../menuTool";
import store from "@/store";
import {
  selectSuYuan700Byld,
  selectAddrByXY,
  selectSuYuan46ById,
  selectCoords,
} from "@/api/api.js";
const InitMap = {
  earthCtrl: null,
  Viewer: null,
  //地图初始化
  init3DMap() {
    let typearr = ["Billboard", "polygon", "polyline", "wall"];
 
    window.sgworld = new SmartEarth.SGWorld(
      "sdkContainer",
      {
        serve: mapUrl,
        x: 115.95338101508028,
        y: 39.726857627913596,
        z: 447.44939899881655,
        heading: -81.9000473022461,
        pitch: -59.400020599365234,
        roll: -6.248129218058927,
      },
 
      () => {
        typearr.forEach((e) => {
          window.sgworld.ProjectTree.removeAll(e);
        });
        window.sgworld.Core.postMessage({ type: "delete" });
        window.sgworld.Core.postMessage({ duoceng: "delete" });
        window.sgworld.Core.postMessage("Type=customewinds;Bool=false;");
        window.sgworld.Core.postMessage({ TypeG1: "Delete" });
        window.sgworld.Core.postMessage({
          func_name: "RemoveGridLines",
          id: "line",
        });
        menuTool.delLine();
        this.addMouseLeftClickEvents();
 
        sgworld.setDefaultCallback((type, data) => {
          // console.log(data);
          if (data) {
            if (data.message) {
              if (data.message == "StartLoad") {
                //加载loading
                store.commit("UPDATE_API_COUNT", "add");
              } else if (data.message == "EndLoad") {
                //减去loading
                store.commit("UPDATE_API_COUNT", "sub");
              }
            }
          }
        });
        //报警
        // data.timer1 = setInterval(() => {
        //   server.bjData();
        // }, 3600000);
        // server.bjData();
      }
    );
  },
  //鼠标左键点击事件添加
  addMouseLeftClickEvents() {
    //点击回调
    window.sgworld.pick(async (data) => {
      if (data.Type) {
        sgworld.Core.postMessage({ func_name: "RemoveGridLines", id: "line" });
        //删除边界
        sgworld.Core.postMessage({
          func_name: "RemoveGridSide",
          id: "boundary",
        });
        var lengthofside = 1000;
        var dt;
        var isSuYuan = 0;
        if (menuTool.oldLeftMenuId == "b2" || menuTool.oldLeftMenuId == "b3") {
          lengthofside = 10000;
          dt = await selectSuYuan700Byld({
            id: data.GridID,
            date: data.Time,
          });
          isSuYuan = 1;
        } else {
          dt = await selectSuYuan46ById({
            id: data.GridID,
            date: data.Time,
          });
        }
 
        if (dt.result) {
          var location = [];
          if (dt.result.x1) {
            location.push({
              lon: dt.result.x1,
              lat: dt.result.y1,
              alt: 150,
              Odds: dt.result.odds1,
              Addr: dt.result.addr1,
            });
          }
          if (dt.result.x2) {
            location.push({
              lon: dt.result.x2,
              lat: dt.result.y2,
              alt: 150,
              Odds: dt.result.odds2,
              Addr: dt.result.addr2,
            });
          }
          if (dt.result.x3) {
            location.push({
              lon: dt.result.x3,
              lat: dt.result.y3,
              alt: 150,
              Odds: dt.result.odds3,
              Addr: dt.result.addr3,
            });
          }
          sgworld.Core.postMessage({
            func_name: "SpawnGridLines",
            StartPointArr: location,
            EndPoint: { endlon: data.lon, endlat: data.lat, endalt: 150 },
            id: "line",
            scale: 30,
            speed: 0.6,
            color: "#ff0000",
            color_strength: 2.0,
            fx_number: 20,
            line_scale: 0.5,
          });
        }
        let addrdt;
        let addr;
 
        var n = data.GridID.split("_");
 
        addrdt = await selectCoords({
          x: n[0],
          y: n[1],
          isSuYuan: isSuYuan,
        });
        if (addrdt.result.length != 0) {
          addr = addrdt.result[0].addr;
        } else {
          addrdt = await selectAddrByXY({
            x: data.lon,
            y: data.lat,
          });
 
          addr = addrdt.result;
        }
 
        sgworld.Core.postMessage({
          func_name: "SpawnGridSide",
          lon: data.lon,
          lat: data.lat,
          alt: 155,
          id: "boundary",
          lengthofside: lengthofside,
          color: "#ff0000",
          emissivestrength: 2.0,
          name: addr,
        });
        store.commit("getWGobj", { lon: data.lon, lat: data.lat });
      }
      if (data.data) {
        if (data.data.type) {
          if (data.data.type == "WY") {
            // dialog.chart_isshow = true;
            store.commit("getPOIname", data.data.name);
 
            store.commit("getPOItype", data.data.type);
            store.commit("getYCstate", Math.random());
            store.commit("getPOIobj", data);
            // if (menuData.leftMenu[1].isActive) {
            //   // dialog.SYbox_isshow = true;
            //   window.sgworld.Navigate.flyToPosition(
            //     data.x,
            //     data.y - 0.002,
            //     400,
            //     {
            //       heading: -90,
            //       pitch: -30,
            //       roll: 0,
            //     }
            //   );
            // }
          }
          if (data.data.type == "CJ") {
            // dialog.chart_isshow = true;
 
            store.commit("getPOIname", data.data.name);
 
            store.commit("getPOItype", data.data.type);
            store.commit("getYCstate", Math.random());
            store.commit("getPOIobj", data);
            // closeChildBtn("网格工具");
            // closeChildBtn("天气特效");
            // closeChildBtn("三维污染物");
            if (menuData.leftMenu[1].isActive) {
              // dialog.SYbox_isshow = true;
              window.sgworld.Navigate.flyToPosition(
                data.x,
                data.y - 0.003,
                500,
                {
                  heading: -90,
                  pitch: -30,
                  roll: 0,
                }
              );
            }
          }
          if (data.data.type == "SS") {
            // dialog.chart_isshow = true;
 
            store.commit("getPOIname", data.data.name);
 
            store.commit("getPOItype", data.data.type);
            store.commit("getYCstate", Math.random());
            // store.commit("getPOIobj", data);
            // closeChildBtn("网格工具");
            // closeChildBtn("天气特效");
            // closeChildBtn("三维污染物");
          }
        }
      }
    });
  },
};
export default InitMap;