//服务加载配置文件 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) => { 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;