From 368cadf28a912e35bd9d8017588cb0aefffc7b79 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 08 Mar 2022 17:10:48 +0800
Subject: [PATCH] 二维码扫码与PC端DC使用方式更换

---
 src/components/campusNav/index.vue |   76 ++++++++++++++++++-------------------
 1 files changed, 37 insertions(+), 39 deletions(-)

diff --git a/src/components/campusNav/index.vue b/src/components/campusNav/index.vue
index ee06236..6550915 100644
--- a/src/components/campusNav/index.vue
+++ b/src/components/campusNav/index.vue
@@ -79,7 +79,6 @@
         return {
             tabOneFlag: true,
             tabTwoFlag: false,
-            DC: null,
             navigationWay: '步行',
             routeLayer: null,
             toNameText: '',
@@ -142,7 +141,6 @@
         }
     },
     created () {
-        this.DC = global.DC
     },
     mounted () {
         const leftBut = document.querySelectorAll('.el-input-group__prepend')
@@ -163,15 +161,15 @@
                 if (val == 'start') {
                     // 初始化图标图层
                     if (this.endLayer == null) {
-                        this.endLayer = new this.DC.VectorLayer('endLayer')
+                        this.endLayer = new global.DC.VectorLayer('endLayer')
                         this.viewer.addLayer(this.endLayer)
                     } else {
                         this.endLayer.clear()
                     }
                     // console.log("baoliuend", "see");
                     that.$store.commit('SET_STARTINGPOINT', [])
-                    const endEntity = new that.DC.Billboard(
-                        new that.DC.Position(
+                    const endEntity = new global.DC.Billboard(
+                        new global.DC.Position(
                             Number(this.terminus[0]),
                             Number(this.terminus[1]),
                             Number(this.terminus[2])
@@ -182,15 +180,15 @@
                 } else if (val == 'end') {
                     // 初始化图标图层
                     if (this.startLayer == null) {
-                        this.startLayer = new this.DC.VectorLayer('startLayer')
+                        this.startLayer = new global.DC.VectorLayer('startLayer')
                         this.viewer.addLayer(this.startLayer)
                     } else {
                         this.startLayer.clear()
                     }
                     // console.log("baoliustart", "see");
                     that.$store.commit('SET_TERMINUS', [])
-                    const startEntity = new that.DC.Billboard(
-                        new that.DC.Position(
+                    const startEntity = new global.DC.Billboard(
+                        new global.DC.Position(
                             Number(this.startingPoint[0]),
                             Number(this.startingPoint[1]),
                             Number(this.startingPoint[2])
@@ -213,7 +211,7 @@
                 title = '点击选择起点'
                 // 初始化图标图层
                 if (this.startLayer == null) {
-                    this.startLayer = new this.DC.VectorLayer('startLayer')
+                    this.startLayer = new global.DC.VectorLayer('startLayer')
                     this.viewer.addLayer(this.startLayer)
                 } else {
                     this.startLayer.clear()
@@ -222,7 +220,7 @@
                 title = '点击选择终点'
                 // 初始化图标图层
                 if (this.endLayer == null) {
-                    this.endLayer = new this.DC.VectorLayer('endLayer')
+                    this.endLayer = new global.DC.VectorLayer('endLayer')
                     this.viewer.addLayer(this.endLayer)
                 } else {
                     this.endLayer.clear()
@@ -230,7 +228,7 @@
             }
             that.overChouse = false // 开启事件
             // 地图选点
-            that.clicks = that.viewer.on(that.DC.MouseEventType.CLICK, (e) => {
+            that.clicks = that.viewer.on(global.DC.MouseEventType.CLICK, (e) => {
                 if (that.overChouse) {
                     return
                 }
@@ -243,8 +241,8 @@
                     // 传输坐标数据
                     that.$store.commit('SET_STARTINGPOINT', [...lnglat, 0])
                     // 起点
-                    const startEntity = new that.DC.Billboard(
-                        new that.DC.Position(
+                    const startEntity = new global.DC.Billboard(
+                        new global.DC.Position(
                             Number(lnglat[0]),
                             Number(lnglat[1]),
                             Number(0)
@@ -257,8 +255,8 @@
                     // 传输坐标数据
                     that.$store.commit('SET_TERMINUS', [...lnglat, 0])
                     // 终点
-                    const endEntity = new that.DC.Billboard(
-                        new that.DC.Position(
+                    const endEntity = new global.DC.Billboard(
+                        new global.DC.Position(
                             Number(lnglat[0]),
                             Number(lnglat[1]),
                             Number(0)
@@ -273,7 +271,7 @@
                 // 开启其他地图事件
                 that.$store.commit('set_closeMapClick', false)
             })
-            that.moves = that.viewer.on(that.DC.MouseEventType.MOUSE_MOVE, (e) => {
+            that.moves = that.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, (e) => {
                 if (that.overChouse) {
                     return
                 }
@@ -332,7 +330,7 @@
             }
 
             if (this.routeLayer == null) {
-                this.routeLayer = new this.DC.VectorLayer('navigation')
+                this.routeLayer = new global.DC.VectorLayer('navigation')
                 this.viewer.addLayer(this.routeLayer)
             } else {
                 this.routeLayer.clear()
@@ -344,9 +342,9 @@
                 this.$message('请输入终点!!!')
             }
 
-            // var start = this.DC.Transform.transformWGS84ToCartesian()
-            const startEntity = new this.DC.Billboard(
-                new this.DC.Position(
+            // var start = global.DC.Transform.transformWGS84ToCartesian()
+            const startEntity = new global.DC.Billboard(
+                new global.DC.Position(
                     Number(this.startingPoint[0]),
                     Number(this.startingPoint[1]),
                     Number(this.startingPoint[2])
@@ -354,9 +352,9 @@
                 '/img/navicon/start.png'
             )
             this.routeLayer.addOverlay(startEntity)
-            // var end = this.DC.Transform.transformWGS84ToCartesian()
-            const endEntity = new this.DC.Billboard(
-                new this.DC.Position(
+            // var end = global.DC.Transform.transformWGS84ToCartesian()
+            const endEntity = new global.DC.Billboard(
+                new global.DC.Position(
                     Number(this.terminus[0]),
                     Number(this.terminus[1]),
                     Number(this.terminus[2])
@@ -372,8 +370,8 @@
             var endLog = Number(this.terminus[0]).toFixed(6)
             var endLat = Number(this.terminus[1]).toFixed(6)
 
-            var origin = this.DC.CoordTransform.WGS84ToGCJ02(startLog, startLat)
-            var destination = this.DC.CoordTransform.WGS84ToGCJ02(endLog, endLat)
+            var origin = global.DC.CoordTransform.WGS84ToGCJ02(startLog, startLat)
+            var destination = global.DC.CoordTransform.WGS84ToGCJ02(endLog, endLat)
 
             if (this.navigationWay == '步行') {
                 axios
@@ -407,7 +405,7 @@
                             item.polyline.forEach((it) => {
                                 it = it.split(',')
                                 lineArr.push(
-                                    this.DC.CoordTransform.GCJ02ToWGS84(it[0], it[1]).join(',')
+                                    global.DC.CoordTransform.GCJ02ToWGS84(it[0], it[1]).join(',')
                                 )
                             })
 
@@ -423,11 +421,11 @@
                         routes =
                             startLog + ',' + startLat + ';' + routes + endLog + ',' + endLat
 
-                        const polyline = new this.DC.Polyline(routes)
+                        const polyline = new global.DC.Polyline(routes)
                         polyline.setStyle({
                             width: 3,
-                            material: new this.DC.PolylineTrailMaterialProperty({
-                                color: this.DC.Color.RED,
+                            material: new global.DC.PolylineTrailMaterialProperty({
+                                color: global.DC.Color.RED,
                                 speed: 10
                             }),
                             clampToGround: true
@@ -456,16 +454,16 @@
                             this.viewer.camera.setView({
                                 // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                                 // fromDegrees()方法,将经纬度和高程转换为世界坐标
-                                destination: this.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+                                destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                                     longitude,
                                     latitude,
                                     600
                                 ),
                                 orientation: {
                                     // 指向
-                                    heading: this.DC.Namespace.Cesium.Math.toRadians(0, 0),
+                                    heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                     // 视角
-                                    pitch: this.DC.Namespace.Cesium.Math.toRadians(-90),
+                                    pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                     roll: 0.0
                                 }
                             })
@@ -493,7 +491,7 @@
                             item.polyline.forEach((it) => {
                                 it = it.split(',')
                                 lineArr.push(
-                                    this.DC.CoordTransform.GCJ02ToWGS84(it[0], it[1]).join(',')
+                                    global.DC.CoordTransform.GCJ02ToWGS84(it[0], it[1]).join(',')
                                 )
                             })
 
@@ -507,11 +505,11 @@
                         routes =
                             startLog + ',' + startLat + ';' + routes + endLog + ',' + endLat
 
-                        const polyline = new this.DC.Polyline(routes)
+                        const polyline = new global.DC.Polyline(routes)
                         polyline.setStyle({
                             width: 3,
-                            material: new this.DC.PolylineTrailMaterialProperty({
-                                color: this.DC.Color.RED,
+                            material: new global.DC.PolylineTrailMaterialProperty({
+                                color: global.DC.Color.RED,
                                 speed: 10
                             }),
                             clampToGround: true
@@ -541,16 +539,16 @@
                             this.viewer.camera.setView({
                                 // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                                 // fromDegrees()方法,将经纬度和高程转换为世界坐标
-                                destination: this.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+                                destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                                     longitude,
                                     latitude,
                                     600
                                 ),
                                 orientation: {
                                     // 指向
-                                    heading: this.DC.Namespace.Cesium.Math.toRadians(0, 0),
+                                    heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                     // 视角
-                                    pitch: this.DC.Namespace.Cesium.Math.toRadians(-90),
+                                    pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                     roll: 0.0
                                 }
                             })

--
Gitblit v1.9.3