From e733164e1c779b3aef7245936b9daf7875bf791e Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 14 Dec 2023 17:12:33 +0800
Subject: [PATCH] 解决屏幕缩放导致鼠标位置不准确的问题,右侧,切换校区后的显示BUG

---
 src/components/mobileWindow/index.vue |  105 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 75 insertions(+), 30 deletions(-)

diff --git a/src/components/mobileWindow/index.vue b/src/components/mobileWindow/index.vue
index 239a65b..3558a19 100644
--- a/src/components/mobileWindow/index.vue
+++ b/src/components/mobileWindow/index.vue
@@ -74,6 +74,42 @@
 import { mapGetters } from 'vuex'
 import { GCJ02ToWGS84 } from '@/utils/CoordTransform'
 
+let extent = [
+    {
+        key: 1,
+        xMin: 112.51303616638316,
+        yMin: -0.103420786429659,
+        xMax: 112.67880038471827,
+        yMax: 0.000004508906477476281,
+        resolution: 0.00001903568804664224,
+
+        x: (x, y) => {
+            return -250.6503 + 2.0389 * x + 4.4338 * y
+        },
+
+        y: (x, y) => {
+            return 228.1454 - 2.321 * x + 1.4165 * y
+        },
+    },
+
+    {
+        key: 2,
+        xMin: 112.51302551881798,
+        yMin: -0.16235359398493399,
+        xMax: 112.72742295590702,
+        yMax: 0.000004509195932360471,
+        resolution: 0.00001903568804664224,
+
+        x: (x, y) => {
+            return -802.9905 + 6.1504 * x + 7.0694 * y
+        },
+
+        y: (x, y) => {
+            return 295.4321 - 3.4878 * x + 3.775 * y
+        },
+    },
+]
+
 export default {
     name: 'mobileWindow',
     computed: {
@@ -123,10 +159,12 @@
         }
     },
 
+    inject: ['mobileMapElement'],
+
     mounted () {
         this.$EventBus.$on('clearTimoutTime', () => {
             if (this.navigationFlag == true) {
-                window.geolocation.clearWatch()
+                // window.geolocation.clearWatch()
 
                 this.$store.dispatch('removeLabelLayerIconMobelUse')
             }
@@ -242,13 +280,14 @@
                 }
             }
 
+            // 需要传入路网url
             that.$store.dispatch('MSET_GOTOWHERE', ints)
         },
 
         getCurrentLocation (flag = true) {
             const that = this
 
-            window.geolocation.watchPosition(that.showPosition)
+            // window.geolocation.watchPosition(that.showPosition)
 
             window.geolocation.getLocation(that.showPosition, that.showErrow, {
                 timeout: 8000
@@ -258,35 +297,41 @@
         showPosition (result) {
             const that = this
 
-            const position = GCJ02ToWGS84(result.lng, result.lat)
+            let cur = extent.find((item) => item.key == this.mobileMapElement.campusValue)
+
+            let positionWgs = GCJ02ToWGS84(result.lng, result.lat)
+
+            let position = {
+                lng: cur.x(positionWgs[0], positionWgs[1]),
+                lat: cur.y(positionWgs[0], positionWgs[1]),
+            }
 
             const data = {
                 name: '我的位置',
-                jd: position[0],
-                wd: position[1]
+                jd: position.lng,
+                wd: position.lat
             }
-
-            that.$store.dispatch('addLabelLayerIconMobelUse', {
-                data: data,
-                clear: true,
-                mviewer: global.viewer
-            })
 
             if (that.navigationFlag == true) return
 
-            if (position[0] > 115.78815057 && position[0] < 115.80346610 && position[1] > 28.63771847 && position[1] < 28.64981682) {
+            if (
+                position.lng > cur.xMin &&
+                position.lng < cur.xMax &&
+                position.lat > cur.yMin &&
+                position.lat < cur.yMax
+            ) {
                 that.$store.dispatch('pcMoveView', {
-                    jd: position[0],
-                    wd: position[1],
-                    viewer: global.viewer
+                    jd: position.lng,
+                    wd: position.lat,
+                    resolution: cur.resolution,
                 })
 
                 that.$store.dispatch('addLabelLayerIconMobelUse', {
                     data: data,
                     clear: true,
-                    mviewer: global.viewer
                 })
-                that.doit([position[0], position[1]])
+
+                that.doit([position.lng, position.lat])
 
                 that.navigationFlag = true
             } else {
@@ -345,11 +390,11 @@
                         name: '显示活动'
                     })
                     // 暂时关闭去这的功能
-                    // if (queryData.notAddGoOn == 'notAddGoOn') {
-                    //     this.seebut.push({
-                    //         name: '去这'
-                    //     })
-                    // }
+                    if (queryData.notAddGoOn == 'notAddGoOn') {
+                        this.seebut.push({
+                            name: '去这'
+                        })
+                    }
                 }
                 for (const k in this.seebut) {
                     if (this.seebut[k].name == '定位') {
@@ -357,11 +402,11 @@
                     }
                 }
                 // 暂时关闭去这的功能
-                // if (queryData.notAddGoOn != 'notAddGoOn') {
-                //     this.seebut.push({
-                //         name: '去这'
-                //     })
-                // }
+                if (queryData.notAddGoOn != 'notAddGoOn') {
+                    this.seebut.push({
+                        name: '去这'
+                    })
+                }
             } else {
                 this.seebut = [
                     // {
@@ -370,9 +415,9 @@
                     {
                         name: '图集'
                     },
-                    // {
-                    //     name: '去这'
-                    // }
+                    {
+                        name: '去这'
+                    }
                 ]
             }
 

--
Gitblit v1.9.3