From 81773ab04fd259e893c2d7f08dbdc9be772d01c4 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Tue, 21 Dec 2021 17:18:45 +0800
Subject: [PATCH] +,请求数据,弹框显示,优化代码长度

---
 src/store/modules/mobile.js |   86 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/src/store/modules/mobile.js b/src/store/modules/mobile.js
index 3cca045..a99ce68 100644
--- a/src/store/modules/mobile.js
+++ b/src/store/modules/mobile.js
@@ -62,7 +62,9 @@
         },
     },
     actions: {
-        setMobileWindows({ state, commit, }, data) {//打开随地图移动窗口,暂不使用
+        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(
@@ -82,10 +84,31 @@
                 content: document.getElementById("mobile-map_content_content"),
                 position: [data.position],
             });
-            commit("MSET_MOBILEWINDOWSHIDE", false)
-            state.mviewer.zoomToPosition(
-                new global.DC.Position(data.lntLat[0], data.lntLat[1] - 0.012, 1530, 0, -45)
+            // 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 }) {
@@ -98,7 +121,7 @@
             var ellipsoid = state.mviewer.scene.globe.ellipsoid;
             var cartographic = global.DC.Namespace.Cesium.Cartographic.fromDegrees(
                 data.lnt,
-                data.lat - 0.0004,
+                data.lat - 0.00006,
                 data.alt || "90.648862227"
             );
             var position = ellipsoid.cartographicToCartesian(cartographic);
@@ -124,6 +147,59 @@
         //加入当时的选点
         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
+            //     }
+            // });
         }
     }
 }

--
Gitblit v1.9.3