From 9fa6e9ea26470378bec1628de2968d52c3bc135f Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 28 Mar 2022 10:52:30 +0800
Subject: [PATCH] 兼容问题处理

---
 src/components/map/components/dimension.vue |  310 ++++++++++++++++++++++++--------------------------
 1 files changed, 149 insertions(+), 161 deletions(-)

diff --git a/src/components/map/components/dimension.vue b/src/components/map/components/dimension.vue
index 0ec6d09..6d7d2e4 100644
--- a/src/components/map/components/dimension.vue
+++ b/src/components/map/components/dimension.vue
@@ -56,7 +56,8 @@
 let layerSATtwo = null
 let tcLayer = null
 
-let idlerFlag = true
+let viewerHeight = 950
+let smallViewerHeight = 1950
 
 // const wallLayer = null
 
@@ -105,6 +106,7 @@
             // mapCenter: [115.871863, 28.743861, 950.0]
         }
     },
+    props: ['wheelFlag', 'startWheel', 'startSmallWheel'],
     computed: {
         ...mapGetters([
             'viewerExist',
@@ -119,34 +121,6 @@
         select = {
             overlay: null,
             color: null
-        }
-
-        windowAddMouseWheel()
-        function windowAddMouseWheel () {
-            var scrollFunc = function (e) {
-                e = e || window.event
-                if (e.wheelDelta) { // 判断浏览器IE,谷歌滑轮事件
-                    if (e.wheelDelta > 0) { // 当滑轮向上滚动时
-                        idlerFlag = false
-                    }
-                    if (e.wheelDelta < 0) { // 当滑轮向下滚动时
-                        idlerFlag = true
-                    }
-                } else if (e.detail) { // Firefox滑轮事件
-                    if (e.detail > 0) { // 当滑轮向上滚动时
-                        idlerFlag = false
-                    }
-                    if (e.detail < 0) { // 当滑轮向下滚动时
-                        idlerFlag = true
-                    }
-                }
-            }
-            // 给页面绑定滑轮滚动事件
-            if (document.addEventListener) { // 火狐使用DOMMouseScroll绑定
-                document.addEventListener('DOMMouseScroll', scrollFunc, false)
-            }
-            // 其他浏览器直接绑定滚动事件
-            window.onmousewheel = document.onmousewheel = scrollFunc
         }
     },
     watch: {
@@ -488,7 +462,7 @@
                                     destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                                         that.mapCenter[0],
                                         that.mapCenter[1],
-                                        950.0
+                                        that.mapCenter[2]
                                     ),
                                     orientation: {
                                         // 指向
@@ -507,18 +481,13 @@
                                 that.dimensionValue != undefined &&
                                 that.dimensionValue != '真三维'
                             ) {
-                                const height = Math.ceil(
-                                    global.viewer.camera.positionCartographic.height
-                                )
-
-                                if (height < 575) {
+                                if (viewerHeight == 500) {
                                     global.viewer.camera.setView({
-                                        destination:
-                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                                                global.viewer.camera.positionCartographic.longitude,
-                                                global.viewer.camera.positionCartographic.latitude,
-                                                650
-                                            ),
+                                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                                            global.viewer.camera.positionCartographic.longitude,
+                                            global.viewer.camera.positionCartographic.latitude,
+                                            650
+                                        ),
                                         orientation: {
                                             // 指向
                                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
@@ -527,18 +496,18 @@
                                             roll: 0.0
                                         }
                                     })
-
+                                    viewerHeight = 650
+                                    this.$emit('change-wheel', false, 'startWheel')
                                     return
                                 }
 
-                                if (height < 725) {
+                                if (viewerHeight == 650) {
                                     global.viewer.camera.setView({
-                                        destination:
-                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                                                global.viewer.camera.positionCartographic.longitude,
-                                                global.viewer.camera.positionCartographic.latitude,
-                                                800
-                                            ),
+                                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                                            global.viewer.camera.positionCartographic.longitude,
+                                            global.viewer.camera.positionCartographic.latitude,
+                                            800
+                                        ),
                                         orientation: {
                                             // 指向
                                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
@@ -547,18 +516,18 @@
                                             roll: 0.0
                                         }
                                     })
-
+                                    viewerHeight = 800
+                                    this.$emit('change-wheel', false, 'startWheel')
                                     return
                                 }
 
-                                if (height < 875) {
+                                if (viewerHeight == 800) {
                                     global.viewer.camera.setView({
-                                        destination:
-                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                                                global.viewer.camera.positionCartographic.longitude,
-                                                global.viewer.camera.positionCartographic.latitude,
-                                                950
-                                            ),
+                                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                                            global.viewer.camera.positionCartographic.longitude,
+                                            global.viewer.camera.positionCartographic.latitude,
+                                            950
+                                        ),
                                         orientation: {
                                             // 指向
                                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
@@ -567,6 +536,8 @@
                                             roll: 0.0
                                         }
                                     })
+                                    viewerHeight = 950
+                                    this.$emit('change-wheel', false, 'startWheel')
                                 }
                             }
                         }
@@ -577,18 +548,13 @@
                                 that.dimensionValue != undefined &&
                                 that.dimensionValue != '真三维'
                             ) {
-                                const height = Math.ceil(
-                                    global.viewer.camera.positionCartographic.height
-                                )
-
-                                if (height > 875) {
+                                if (viewerHeight == 950) {
                                     global.viewer.camera.setView({
-                                        destination:
-                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                                                global.viewer.camera.positionCartographic.longitude,
-                                                global.viewer.camera.positionCartographic.latitude,
-                                                800
-                                            ),
+                                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                                            global.viewer.camera.positionCartographic.longitude,
+                                            global.viewer.camera.positionCartographic.latitude,
+                                            800
+                                        ),
                                         orientation: {
                                             // 指向
                                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
@@ -597,18 +563,18 @@
                                             roll: 0.0
                                         }
                                     })
-
+                                    viewerHeight = 800
+                                    this.$emit('change-wheel', false, 'startWheel')
                                     return
                                 }
 
-                                if (height > 725) {
+                                if (viewerHeight == 800) {
                                     global.viewer.camera.setView({
-                                        destination:
-                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                                                global.viewer.camera.positionCartographic.longitude,
-                                                global.viewer.camera.positionCartographic.latitude,
-                                                650
-                                            ),
+                                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                                            global.viewer.camera.positionCartographic.longitude,
+                                            global.viewer.camera.positionCartographic.latitude,
+                                            650
+                                        ),
                                         orientation: {
                                             // 指向
                                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
@@ -617,18 +583,18 @@
                                             roll: 0.0
                                         }
                                     })
-
+                                    viewerHeight = 650
+                                    this.$emit('change-wheel', false, 'startWheel')
                                     return
                                 }
 
-                                if (height > 575) {
+                                if (viewerHeight == 650) {
                                     global.viewer.camera.setView({
-                                        destination:
-                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                                                global.viewer.camera.positionCartographic.longitude,
-                                                global.viewer.camera.positionCartographic.latitude,
-                                                500
-                                            ),
+                                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                                            global.viewer.camera.positionCartographic.longitude,
+                                            global.viewer.camera.positionCartographic.latitude,
+                                            500
+                                        ),
                                         orientation: {
                                             // 指向
                                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
@@ -637,12 +603,14 @@
                                             roll: 0.0
                                         }
                                     })
+                                    viewerHeight = 500
+                                    this.$emit('change-wheel', false, 'startWheel')
                                 }
                             }
                         }
 
                     global.viewer.on(global.DC.SceneEventType.CAMERA_CHANGED, that.mapCameraEvent)
-                    // global.eagleViewer.on(global.DC.SceneEventType.CAMERA_CHANGED, that.smallMapCameraEvent)
+                    global.eagleViewer.on(global.DC.SceneEventType.CAMERA_CHANGED, that.smallMapCameraEvent)
                 }
             }
         }
@@ -712,10 +680,6 @@
         },
 
         mapCameraEvent () {
-            const height = Math.ceil(
-                global.viewer.camera.positionCartographic.height
-            )
-
             global.viewer.camera.setView({
                 orientation: {
                     // 指向
@@ -726,26 +690,10 @@
                 }
             })
 
-            if (idlerFlag) { // 下
-                if (height > 810) {
-                    global.viewer.camera.setView({
-                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
-                            950
-                        ),
-                        orientation: {
-                            // 指向
-                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                            // 视角
-                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
-                            roll: 0.0
-                        }
-                    })
-                    return
-                }
+            if (this.startWheel == false) return
 
-                if (height > 660) {
+            if (this.wheelFlag) { // 下
+                if (viewerHeight == 950) {
                     global.viewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                             global.viewer.camera.positionCartographic.longitude,
@@ -760,10 +708,12 @@
                             roll: 0.0
                         }
                     })
+                    viewerHeight = 800
+                    this.$emit('change-wheel', false, 'startWheel')
                     return
                 }
 
-                if (height > 510) {
+                if (viewerHeight == 800) {
                     global.viewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                             global.viewer.camera.positionCartographic.longitude,
@@ -778,9 +728,12 @@
                             roll: 0.0
                         }
                     })
+                    viewerHeight = 650
+                    this.$emit('change-wheel', false, 'startWheel')
+                    return
                 }
-            } else { // 上
-                if (height < 640) {
+
+                if (viewerHeight == 650) {
                     global.viewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                             global.viewer.camera.positionCartographic.longitude,
@@ -795,10 +748,11 @@
                             roll: 0.0
                         }
                     })
-                    return
+                    viewerHeight = 500
+                    this.$emit('change-wheel', false, 'startWheel')
                 }
-
-                if (height < 790) {
+            } else { // 上
+                if (viewerHeight == 500) {
                     global.viewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                             global.viewer.camera.positionCartographic.longitude,
@@ -813,10 +767,12 @@
                             roll: 0.0
                         }
                     })
+                    viewerHeight = 650
+                    this.$emit('change-wheel', false, 'startWheel')
                     return
                 }
 
-                if (height < 940) {
+                if (viewerHeight == 650) {
                     global.viewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                             global.viewer.camera.positionCartographic.longitude,
@@ -831,15 +787,33 @@
                             roll: 0.0
                         }
                     })
+                    viewerHeight = 800
+                    this.$emit('change-wheel', false, 'startWheel')
+                    return
+                }
+
+                if (viewerHeight == 800) {
+                    global.viewer.camera.setView({
+                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                            global.viewer.camera.positionCartographic.longitude,
+                            global.viewer.camera.positionCartographic.latitude,
+                            950
+                        ),
+                        orientation: {
+                            // 指向
+                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
+                            // 视角
+                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
+                            roll: 0.0
+                        }
+                    })
+                    viewerHeight = 950
+                    this.$emit('change-wheel', false, 'startWheel')
                 }
             }
         },
 
         smallMapCameraEvent () {
-            const height = Math.ceil(
-                global.eagleViewer.camera.positionCartographic.height
-            )
-
             global.eagleViewer.camera.setView({
                 orientation: {
                     // 指向
@@ -850,30 +824,14 @@
                 }
             })
 
-            if (idlerFlag) { // 下
-                if (height > 1810) {
-                    global.viewer.camera.setView({
-                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
-                            1950
-                        ),
-                        orientation: {
-                            // 指向
-                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
-                            // 视角
-                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
-                            roll: 0.0
-                        }
-                    })
-                    return
-                }
+            if (this.startSmallWheel == false) return
 
-                if (height > 1660) {
-                    global.viewer.camera.setView({
+            if (this.wheelFlag) { // 下
+                if (smallViewerHeight == 1950) {
+                    global.eagleViewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
+                            global.eagleViewer.camera.positionCartographic.longitude,
+                            global.eagleViewer.camera.positionCartographic.latitude,
                             1800
                         ),
                         orientation: {
@@ -884,14 +842,16 @@
                             roll: 0.0
                         }
                     })
+                    smallViewerHeight = 1800
+                    this.$emit('change-wheel', false, 'startSmallWheel')
                     return
                 }
 
-                if (height > 1510) {
-                    global.viewer.camera.setView({
+                if (smallViewerHeight == 1800) {
+                    global.eagleViewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
+                            global.eagleViewer.camera.positionCartographic.longitude,
+                            global.eagleViewer.camera.positionCartographic.latitude,
                             1650
                         ),
                         orientation: {
@@ -902,13 +862,16 @@
                             roll: 0.0
                         }
                     })
+                    smallViewerHeight = 1650
+                    this.$emit('change-wheel', false, 'startSmallWheel')
+                    return
                 }
-            } else { // 上
-                if (height < 1640) {
-                    global.viewer.camera.setView({
+
+                if (smallViewerHeight == 1650) {
+                    global.eagleViewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
+                            global.eagleViewer.camera.positionCartographic.longitude,
+                            global.eagleViewer.camera.positionCartographic.latitude,
                             1500
                         ),
                         orientation: {
@@ -919,14 +882,15 @@
                             roll: 0.0
                         }
                     })
-                    return
+                    smallViewerHeight = 1500
+                    this.$emit('change-wheel', false, 'startSmallWheel')
                 }
-
-                if (height < 1790) {
-                    global.viewer.camera.setView({
+            } else { // 上
+                if (smallViewerHeight == 1500) {
+                    global.eagleViewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
+                            global.eagleViewer.camera.positionCartographic.longitude,
+                            global.eagleViewer.camera.positionCartographic.latitude,
                             1650
                         ),
                         orientation: {
@@ -937,14 +901,16 @@
                             roll: 0.0
                         }
                     })
+                    smallViewerHeight = 1650
+                    this.$emit('change-wheel', false, 'startSmallWheel')
                     return
                 }
 
-                if (height < 1940) {
-                    global.viewer.camera.setView({
+                if (smallViewerHeight == 1650) {
+                    global.eagleViewer.camera.setView({
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
-                            global.viewer.camera.positionCartographic.longitude,
-                            global.viewer.camera.positionCartographic.latitude,
+                            global.eagleViewer.camera.positionCartographic.longitude,
+                            global.eagleViewer.camera.positionCartographic.latitude,
                             1800
                         ),
                         orientation: {
@@ -955,6 +921,28 @@
                             roll: 0.0
                         }
                     })
+                    smallViewerHeight = 1800
+                    this.$emit('change-wheel', false, 'startSmallWheel')
+                    return
+                }
+
+                if (smallViewerHeight == 1800) {
+                    global.eagleViewer.camera.setView({
+                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
+                            global.eagleViewer.camera.positionCartographic.longitude,
+                            global.eagleViewer.camera.positionCartographic.latitude,
+                            1950
+                        ),
+                        orientation: {
+                            // 指向
+                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
+                            // 视角
+                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
+                            roll: 0.0
+                        }
+                    })
+                    smallViewerHeight = 1950
+                    this.$emit('change-wheel', false, 'startSmallWheel')
                 }
             }
         },
@@ -1289,7 +1277,7 @@
                     destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                         that.mapCenter[0],
                         that.mapCenter[1],
-                        950.0
+                        that.mapCenter[2]
                     ),
                     orientation: {
                         // 指向

--
Gitblit v1.9.3