(function (window, mars3d) { //创建widget类,需要继承BaseWidget class MyWidget extends mars3d.widget.BaseWidget { //外部资源配置 get resources() { return ["work/Sgmn1Sgfx.js", "work/Sgmn2Clmn.js", "work/Sgmn3Jymn.js"]; } //弹窗配置 get view() { return { type: "window", url: "view.html", windowOptions: { width: 358, position: { top: 50, bottom: 30, right: 10, }, }, }; } //初始化[仅执行1次] create() { this.sgmn1Sgfx = new Sgmn1Sgfx(this.map); this.sgmn2Clmn = new Sgmn2Clmn(this.map); this.sgmn3Jymn = new Sgmn3Jymn(this.map); } //每个窗口创建完成后调用 winCreateOK(opt, result) { this.viewWindow = result; } //打开激活 activate() {} //关闭释放 disable() { this.viewWindow = null; this.clearAll(); } //定位到具体点 locateById(x, y) { if (!x || !y) { return; } this.map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(x, y, 2500), duration: 3, orientation: { heading: 0, pitch: Cesium.Math.toRadians(-90), roll: 0, }, }); } //结束模拟 clearAll() { this.sgmn1Sgfx.clearAll(); this.sgmn3Jymn.clearAll(); this.sgmn2Clmn.clearAll(); haoutil.loading.close(); } //======================事故模拟============================= //开始 图上选择事故点 startSelectSgd(callback) { this.sgmn1Sgfx.selectSgd(callback); } //移除事故点 removeSgd() { this.sgmn1Sgfx.removeSgd(); } //是否可以下一步(需要 选择了事故点) check1to2() { //this.stopDraw(); //是否选择了点 if (!this.sgmn1Sgfx.point || this.sgmn1Sgfx.point.length == 0) { window.toastr.error("请先选择事故点!"); return false; } return true; } startSgmn(arg) { var that = this; //如果已有查询结果直接下一步,不用查询 this.sgmn1Sgfx.start(arg, { timelineCallback: function (step) { // 同步时间轴 var dis = that.sgmn1Sgfx.radiusX || 0; that.viewWindow.effactArea(dis); that.viewWindow.timeProgress(step); var comData = that.sgmn1Sgfx.YWpois; that.viewWindow.companyInfo(comData); }, bootstrapTableCallback: function (data) { //同步bootstraptable表格 that.viewWindow.affectInfo(data); }, }); } loadMorePOI() { var that = this; this.sgmn1Sgfx.loadMore(function (data) { that.viewWindow.moreTableList(data); }); } //是否可以下一步(需要 事故模拟动画结束和查询完毕) check2to3() { //this.stopDraw(); if (!this.sgmn1Sgfx.state) { window.toastr.error("请等待模拟结束!"); return this.sgmn1Sgfx.state; } return this.sgmn1Sgfx.state; //事故模拟过程是否结束 } //======================撤离模拟=============================== startSelectCld(callback) { this.sgmn2Clmn.startSelectCld({ lastEllipseData: this.sgmn1Sgfx.extentData, callback: callback, }); } //是否可以下一步(需要 存在事故模拟查询到的点和设置了撤离点) check3to4() { //this.stopDraw(); if (this.sgmn1Sgfx.point.length == 0) { haoutil.msg("没有受影响的点!"); return false; } if (!this.sgmn2Clmn.points || this.sgmn2Clmn.points.length == 0) { haoutil.msg("请设置撤离点!"); return false; } return true; } cheliDotNum() { return this.sgmn2Clmn.points.length; } //根据id删除对应的撤离点 removeCLPointById(id) { if (!id) { return; } this.sgmn2Clmn.removePointById(id); this.sgmn2Clmn.removeLineAboutByPointId(id); } //计算撤离路线 startClmn() { var that = this; var affectedPointArr = this.sgmn1Sgfx.allPois; if (affectedPointArr.length > 50) { haoutil.msg("当前计算路线过多,仅分析前50个点!"); affectedPointArr = affectedPointArr.slice(0, 50); } this.viewWindow.showRes(false); haoutil.msg("正在计算" + affectedPointArr.length + "个路线……"); haoutil.loading.show(); this.sgmn2Clmn.start({ affectedPointArr: affectedPointArr, callback: function (dataArr) { haoutil.loading.close(); //所有路线信息 that.viewWindow.safeLine(dataArr); that.viewWindow.showRes(true); that.viewWindow.clearLeave(); }, noComputeCallback: function () { haoutil.loading.close(); that.viewWindow.showRes(true); }, }); } //漫游之前 先读取速度设置 roamClmnOne(id, speed) { if (!id) { return; } //停止救援模拟 this.sgmn3Jymn.stopAllRoam(); this.sgmn3Jymn.resetAllLineStyle(); this.closeAllPopup(); this.sgmn2Clmn.roamOneById(id); this.sgmn2Clmn.updatePlaySpeed(speed || 120); this.showHidelineByid(id, true); this.sgmn2Clmn.hightOneLineById(id); //高亮 } //撤离速度动态变化 updateCLPlaySpeed(speed) { this.sgmn2Clmn.updatePlaySpeed(speed || 120); } roamClmnArr(ids, speed) { if (!ids || ids.length == 0) { return; } //停止救援模拟 this.sgmn3Jymn.stopAllRoam(); this.sgmn3Jymn.resetAllLineStyle(); this.closeAllPopup(); this.sgmn2Clmn.resetAllLineStyle(); this.sgmn2Clmn.roamArrByIds(ids); this.sgmn2Clmn.updatePlaySpeed(speed || 120); } resetAllLineStyleCL() { this.sgmn2Clmn.resetAllLineStyle(); } stopRoamClmnArr(ids) { if (!ids || ids.length == 0) { return; } this.closeAllPopup(); this.sgmn2Clmn.stopRoamArrByIds(ids); } showHidelineByid(id, isShow) { if (!id) { return; } this.sgmn2Clmn.showHideLineById(id, isShow); } showHideAllLine(isShow) { this.sgmn2Clmn.showHideAllLine(isShow); } getMaxFlylineTime() { return this.sgmn2Clmn.getMaxFlylineTime(); } //是否可以下一步(需要 路线全部分析完毕) check4to5() { //this.stopDraw(); return this.sgmn2Clmn.state; } //===========================救援模拟================================== startSelectJyd(callback) { this.sgmn3Jymn.startSelectJyd({ callback: callback, }); } //是否可以下一步(需要 存在事故模拟查询到的点 和 设置了撤离点) check5to6() { //this.stopDraw(); if (this.sgmn1Sgfx.pois.length == 0) { haoutil.msg("没有受影响的点!"); return false; } if (!this.sgmn3Jymn.points || this.sgmn3Jymn.points.length == 0) { haoutil.msg("请设置救援点!"); return false; } return true; } //计算救援路线 startJymn() { var that = this; haoutil.loading.show(); this.viewWindow.showPro(false); this.sgmn3Jymn.start({ incidentLnglat: this.sgmn1Sgfx.point, callback: function (dataArr) { haoutil.loading.close(); //所有路线信息 that.viewWindow.rescueLine(dataArr); that.viewWindow.showPro(true); that.viewWindow.clearRescue(); }, noComputeCallback: function () { that.viewWindow.showPro(true); haoutil.loading.close(); }, }); } //根据id删除对应的救援点 removeJYPointById(id) { if (!id) { return; } this.sgmn3Jymn.removePointById(id); this.sgmn3Jymn.removeLineAboutByPointId(id); } roamJymnOne(id, speed) { if (!id) { return; } //停止撤离模拟 this.sgmn2Clmn.stopAllRoam(); this.sgmn2Clmn.resetAllLineStyle(); this.closeAllPopup(); this.sgmn3Jymn.roamOneById(id); this.sgmn3Jymn.updatePlaySpeed(speed || 120); this.sgmn3Jymn.hightOneLineById(id); //高亮 this.showHidelineByid_JY(id, true); } getOneTimeById(id) { if (!id) { return; } var times; times = this.sgmn2Clmn.getFlylineById(id).alltimes; return times; } getOtherOneTimeById(id) { if (!id) { return; } var times; times = this.sgmn3Jymn.getFlylineById(id).alltimes; return times; } roamJymnArr(ids, speed) { if (!ids || ids.length == 0) { return; } //停止撤离模拟 this.sgmn2Clmn.stopAllRoam(); this.sgmn2Clmn.resetAllLineStyle(); this.closeAllPopup(); this.sgmn3Jymn.resetAllLineStyle(); this.sgmn3Jymn.roamArrByIds(ids); this.sgmn3Jymn.updatePlaySpeed(speed || 120); } resetAllLineStyleJY() { this.sgmn3Jymn.resetAllLineStyle(); } stopJymnArr(ids) { if (!ids || ids.length == 0) { return; } this.closeAllPopup(); this.sgmn3Jymn.stopRoamArrByIds(ids); } showHidelineByid_JY(id, isShow) { if (!id) { return; } this.sgmn3Jymn.showHideLineById(id, isShow); } showHideAllLine_JY(isShow) { this.sgmn3Jymn.showHideAllLine(isShow); } getMaxFlylineTime_JY() { return this.sgmn3Jymn.getMaxFlylineTime(); } //救援速度动态变化 updateJYPlaySpeed(speed) { this.sgmn3Jymn.updatePlaySpeed(speed || 120); } stopDraw() { this.sgmn2Clmn.stopDraw(); this.sgmn3Jymn.stopDraw(); this.sgmn1Sgfx.stopDraw(); } closeAllPopup() { this.map.closePopup(); } } //注册到widget管理器中。 mars3d.widget.bindClass(MyWidget); //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。 })(window, mars3d);