From 234e94f3328233067fae84a8c37bebd9afb4bba7 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Wed, 09 Feb 2022 17:20:30 +0800
Subject: [PATCH] +放大缩小改为flyTo

---
 src/components/mobilemap/index.vue |  122 ++++++++--------------------------------
 1 files changed, 24 insertions(+), 98 deletions(-)

diff --git a/src/components/mobilemap/index.vue b/src/components/mobilemap/index.vue
index ac9dca2..ec5070b 100644
--- a/src/components/mobilemap/index.vue
+++ b/src/components/mobilemap/index.vue
@@ -302,6 +302,24 @@
       });
 
       // 按钮事件
+      let butSetViews = (num) => {
+        viewer.camera.flyTo({
+          destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
+            viewer.camera.positionCartographic.longitude,
+            viewer.camera.positionCartographic.latitude,
+            num
+          ),
+          orientation: {
+            // 指向
+            heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
+            // 视角
+            pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
+            roll: 0.0,
+          },
+          duration: 0.5, // 定位的时间间隔
+        });
+        overii();
+      };
       that.butbut = function () {
         //放大
         document.querySelector(".dc-zoom-controller").children[0].onclick =
@@ -311,58 +329,17 @@
                 viewer.camera.positionCartographic.height
               );
               if (height > 180) {
-                viewer.camera.setView({
-                  destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                    viewer.camera.positionCartographic.longitude,
-                    viewer.camera.positionCartographic.latitude,
-                    160
-                  ),
-                  orientation: {
-                    // 指向
-                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                    // 视角
-                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                  },
-                });
-
+                butSetViews(160);
                 return;
               }
 
               if (height > 140) {
-                viewer.camera.setView({
-                  destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                    viewer.camera.positionCartographic.longitude,
-                    viewer.camera.positionCartographic.latitude,
-                    120
-                  ),
-                  orientation: {
-                    // 指向
-                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                    // 视角
-                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                  },
-                });
-
+                butSetViews(120);
                 return;
               }
 
               if (height > 100) {
-                viewer.camera.setView({
-                  destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                    viewer.camera.positionCartographic.longitude,
-                    viewer.camera.positionCartographic.latitude,
-                    80
-                  ),
-                  orientation: {
-                    // 指向
-                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                    // 视角
-                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                  },
-                });
+                butSetViews(80);
               }
             }
           };
@@ -376,54 +353,15 @@
               console.log(height);
 
               if (height <= 100) {
-                viewer.camera.setView({
-                  destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                    viewer.camera.positionCartographic.longitude,
-                    viewer.camera.positionCartographic.latitude,
-                    120
-                  ),
-                  orientation: {
-                    // 指向
-                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                    // 视角
-                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                  },
-                });
+                butSetViews(120);
               }
 
               if (height > 100 && height <= 140) {
-                viewer.camera.setView({
-                  destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                    viewer.camera.positionCartographic.longitude,
-                    viewer.camera.positionCartographic.latitude,
-                    160
-                  ),
-                  orientation: {
-                    // 指向
-                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                    // 视角
-                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                  },
-                });
+                butSetViews(160);
               }
 
               if (height > 140 && height < 180) {
-                viewer.camera.setView({
-                  destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                    viewer.camera.positionCartographic.longitude,
-                    viewer.camera.positionCartographic.latitude,
-                    200
-                  ),
-                  orientation: {
-                    // 指向
-                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                    // 视角
-                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                  },
-                });
+                butSetViews(200);
               }
             }
           };
@@ -453,18 +391,6 @@
               },
               duration: 0.5, // 定位的时间间隔
             });
-            // that.$store.dispatch("mapFlyTo", {
-            //   //飞入
-            //   lntLat: [
-            //     viewer.camera.positionCartographic.longitude,
-            //     viewer.camera.positionCartographic.latitude,
-            //     num,
-            //   ],
-            //   heading: 0,
-            //   pitch: -90,
-            //   roll: 0.0,
-            //   noOpen: true,
-            // });
             overii();
           },
           isCameraTime = null;

--
Gitblit v1.9.3