| | |
| | | import $store from '../index' |
| | | const mobile = { |
| | | state: { |
| | | mviewer: null |
| | | mviewer: null,//地图实体类 |
| | | mBigPopup: false,//全屏弹窗 |
| | | popupOurOpenData: [],//全屏弹窗中下拉菜单数据 |
| | | popupTableName: [],//全屏弹窗标签页数据 |
| | | mBigPopupAfter: false,////全屏弹窗之前的弹窗 |
| | | ips: '',//获取的ip |
| | | iconHide: false,//右侧伸缩状态 |
| | | // DC: '',//DC全局保存 |
| | | MobileWindowsHide: true,//改变点击窗口的显示状态 |
| | | MobileWindowChangeData: false,//改变点击窗口的数据 |
| | | popupsDom: '',//mobileDivForms的实体类 |
| | | query: {},//传输数据 |
| | | openmobileGoTo: false,//测试 |
| | | openmobilePanorama: false,//实景显影 |
| | | MobileWindowsHideFixed: true,//改变点击窗口的显示状态--固定窗口 |
| | | MobileWindowChangeDataFixed: false,//改变点击窗口的数据--固定窗口 |
| | | }, |
| | | mutations: { |
| | | MSET_VIEWER(state, viewer) { |
| | | state.mviewer = viewer |
| | | } |
| | | }, |
| | | MSET_BIGPOPUP(state, viewer) { |
| | | state.mBigPopup = viewer; |
| | | $store.dispatch("closeMobileWindowsDom"); //关闭弹窗 |
| | | }, |
| | | MSET_BIGPOPUPAFTER(state, viewer) { |
| | | state.mBigPopupAfter = viewer; |
| | | $store.dispatch("closeMobileWindowsDom"); //关闭弹窗 |
| | | }, |
| | | MSET_POPUPOUROPENDATA(state, viewer) { |
| | | state.popupOurOpenData = viewer; |
| | | }, |
| | | MSET_ICONHIDE(state, viewer) { |
| | | state.iconHide = viewer |
| | | }, |
| | | MSET_POPUPTABLENAME(state, viewer) { |
| | | state.popupTableName = viewer |
| | | }, |
| | | MSET_MOBILEWINDOWSHIDE(state, viewer) {//随地图移动窗口 |
| | | state.MobileWindowChangeData = !state.MobileWindowChangeData; |
| | | state.MobileWindowsHide = viewer |
| | | }, |
| | | MSET_POPUPDOM(state, viewer) { |
| | | state.popupsDom = viewer |
| | | }, |
| | | MSET_QUERY(state, viewer) { |
| | | state.query = viewer |
| | | }, |
| | | MSET_OPENMOBILEGOTO(state, viewer) { |
| | | state.openmobileGoTo = viewer |
| | | }, |
| | | MSET_OPENMOBILEPANORAMA(state, viewer) { |
| | | state.openmobilePanorama = viewer |
| | | }, |
| | | MSET_MOBILEWINDOWSHIDEFIXED(state, viewer) {//固定窗口 |
| | | state.MobileWindowChangeDataFixed = !state.MobileWindowChangeDataFixed; |
| | | state.MobileWindowsHideFixed = viewer |
| | | console.log(state.MobileWindowChangeDataFixed); |
| | | }, |
| | | }, |
| | | actions: { |
| | | setMobileWindows({ state, commit, dispatch }, data) {//打开随地图移动窗口 |
| | | // 关闭前一个弹窗? |
| | | dispatch("closeMobileWindowsDom"); |
| | | if (data.useJWD) { |
| | | var ellipsoid = state.mviewer.scene.globe.ellipsoid; |
| | | var cartographic = global.DC.Namespace.Cesium.Cartographic.fromDegrees( |
| | | data.lntLat[0], |
| | | data.lntLat[1] - 0.00006, |
| | | "90.648862227" |
| | | ); |
| | | data.position = ellipsoid.cartographicToCartesian(cartographic); |
| | | } |
| | | // 传递响应数据 |
| | | commit("MSET_QUERY", data); |
| | | // 定制化窗体 |
| | | let popupsDom = new global.DC.mobileDivForms(state.mviewer, { |
| | | domId: "mobilePopup", |
| | | title: data.query.name || "成教楼 ", |
| | | className: "mobilePopup", |
| | | content: document.getElementById("mobile-map_content_content"), |
| | | position: [data.position], |
| | | }); |
| | | // commit("MSET_MOBILEWINDOWSHIDE", false)//显示弹窗 |
| | | // dispatch("CHANGETOC3", { // 转换坐标 |
| | | // lnt: data.lntLat[0], |
| | | // lat: data.lntLat[1] |
| | | // }).then(res => { |
| | | // console.log(res) |
| | | |
| | | //基于高度基础设置 |
| | | // h:1530 |
| | | // lnt: + 0.01187 x轴 |
| | | // Lat + 0.0108 y轴 |
| | | let Position = new global.DC.Position(//转坐标 |
| | | +data.lntLat[0] + 0.01187, |
| | | +data.lntLat[1] - 0.0108, |
| | | 1530, |
| | | 0, |
| | | -45 |
| | | ); |
| | | dispatch("mapFlyTo", {//飞入 |
| | | lntLat: [Position.lng, Position.lat, Position.alt], |
| | | heading: Position.heading, |
| | | pitch: Position.pitch, |
| | | roll: Position.roll, |
| | | }) |
| | | // }) |
| | | commit("MSET_POPUPDOM", popupsDom) |
| | | }, |
| | | closeMobileWindowsDom({ state, commit }) { |
| | | if (!state.MobileWindowsHide && state.popupsDom) { |
| | | state.popupsDom.closeOur(); |
| | | commit("MSET_MOBILEWINDOWSHIDE", true); |
| | | } |
| | | }, |
| | | CHANGETOC3({ state, commit }, data) {// //转换经纬度坐标 成世界坐标cartesian3 |
| | | var ellipsoid = state.mviewer.scene.globe.ellipsoid; |
| | | var cartographic = global.DC.Namespace.Cesium.Cartographic.fromDegrees( |
| | | data.lnt, |
| | | data.lat - 0.00006, |
| | | data.alt || "90.648862227" |
| | | ); |
| | | var position = ellipsoid.cartographicToCartesian(cartographic); |
| | | return position; |
| | | }, |
| | | SET_OPENWIDOWFIXED({ state, commit }, data) { |
| | | // 传递响应数据 |
| | | commit("MSET_QUERY", data); |
| | | //显示窗口 |
| | | commit("MSET_MOBILEWINDOWSHIDEFIXED", false) |
| | | //移动地图位置 |
| | | state.mviewer.zoomToPosition( |
| | | new global.DC.Position(data.lntLat[0], data.lntLat[1] - 0.012, 1530, 0, -45) |
| | | ); |
| | | }, |
| | | CLOSE_WIDOWFIXED({ state, commit }) { |
| | | //隐藏窗口 |
| | | if (!state.MobileWindowsHideFixed) { |
| | | console.log(state.MobileWindowsHideFixed) |
| | | commit("MSET_MOBILEWINDOWSHIDEFIXED", true) |
| | | } |
| | | }, |
| | | //加入当时的选点 |
| | | JOIN_POINT({ state, commit }, data) { |
| | | |
| | | }, |
| | | //flyTo |
| | | mapFlyTo({ state, commit, dispatch }, data) { |
| | | state.mviewer.camera.flyTo({ |
| | | destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees( |
| | | data.lntLat[0] - 0.012, data.lntLat[1], |
| | | data.lntLat[2] || 15000.0 |
| | | ), |
| | | // destination: data.res, |
| | | orientation: { |
| | | heading: global.DC.Namespace.Cesium.Math.toRadians(data.heading), |
| | | pitch: global.DC.Namespace.Cesium.Math.toRadians(data.pitch), |
| | | // heading: data.heading, |
| | | // pitch: data.pitch, |
| | | roll: data.roll |
| | | }, |
| | | duration: 2, //定位的时间间隔 |
| | | complete: () => {//完成后的回调 |
| | | setTimeout(() => { |
| | | !state.MobileWindowsHide || |
| | | commit("MSET_MOBILEWINDOWSHIDE", false)//显示弹窗 |
| | | }, 0); |
| | | } |
| | | }); |
| | | //官网flyto使用方法 |
| | | // 1. Fly to a position with a top-down view |
| | | // viewer.camera.flyTo({ |
| | | // destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0) |
| | | // }); |
| | | |
| | | // // 2. Fly to a Rectangle with a top-down view |
| | | // viewer.camera.flyTo({ |
| | | // destination : Cesium.Rectangle.fromDegrees(west, south, east, north) |
| | | // }); |
| | | |
| | | // // 3. Fly to a position with an orientation using unit vectors. |
| | | // viewer.camera.flyTo({ |
| | | // destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0), |
| | | // orientation : { |
| | | // direction : new Cesium.Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734), |
| | | // up : new Cesium.Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339) |
| | | // } |
| | | // }); |
| | | |
| | | // // 4. Fly to a position with an orientation using heading, pitch and roll. |
| | | // viewer.camera.flyTo({ |
| | | // destination : Cesium.Cartesian3.fromDegrees(-122.19, 46.25, 5000.0), |
| | | // orientation : { |
| | | // heading : Cesium.Math.toRadians(175.0), |
| | | // pitch : Cesium.Math.toRadians(-35.0), |
| | | // roll : 0.0 |
| | | // } |
| | | // }); |
| | | } |
| | | } |
| | | } |
| | | |