From e3dcaeb0180a4e37347ac9ceb44c8a59ae7af37f Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Mon, 21 Feb 2022 19:40:20 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/qfqk-android

---
 leafletMapOur/loginMap/js/vueMain.js |   88 +++++++++++++++++++++++++++-----------------
 1 files changed, 54 insertions(+), 34 deletions(-)

diff --git a/leafletMapOur/loginMap/js/vueMain.js b/leafletMapOur/loginMap/js/vueMain.js
index 61f8ae8..faf0089 100644
--- a/leafletMapOur/loginMap/js/vueMain.js
+++ b/leafletMapOur/loginMap/js/vueMain.js
@@ -22,11 +22,13 @@
         resultFeedbackPopupShow: false,
         popupDisplay: "none",
 
-        regionName: ''
+        regionName: '',
+        byValue: ''
     },
     methods: {
         getLocalPoliceStation () {
-            window.parent.getRegionName(this.regionName)
+            this.regionName = this.byValue
+
         },
         getDataList () {
             var that = this
@@ -45,7 +47,6 @@
             //url解码
             this.getdata = this.getQueryVariable('data') || data
 
-            console.log(this.getdata, 456)
             this.map = this.beginMap(this.map, this.getdata) //创建并接受map
             this.map.invalidateSize(true) //应用地图高度
         },
@@ -111,61 +112,80 @@
         getLocationData () {
             var that = this
             var geolocation = new qq.maps.Geolocation("T7RBZ-62U3X-RSQ4P-ZZVCB-WE7JT-HRBOG", "mapqq")
-            var positionNum = 0
-            var options = {
-                timeout: 8000
-            }
 
+            var options = {
+                timeout: 8000 //延时
+            }
+            var geocoder
+            var latLng
+            // 定位成功之后调用的方法
             function showPosition (position) {
 
-                that.regionName = position.district || position.city
+                that.byValue = position.district || position.city
 
-                console.log(position)
-
-                var adCode = position.adCode //邮政编码
-                var nation = position.nation //中国
-                var city = position.city //城市
-                var addr = position.addr //详细地址
                 that.lat = position.lat //
                 that.lng = position.lng //火星坐标 //TODO 实现业务代码逻辑 
 
-                if (that.LXdhStart != null) {
-                    that.map.removeLayer(that.LXdhStart)
-                }
+                // 逆地址解析(经纬度到地名转换过程)
+                geocoder = new qq.maps.Geocoder({
+                    complete: function (res) {
+                        if (that.LXdhStart != null) {
+                            that.map.removeLayer(that.LXdhStart)
+                        }
 
-                //绘制起点和终点
-                that.LXdhStart = L.markerClusterGroup()
+                        //绘制起点和终点
+                        that.LXdhStart = L.markerClusterGroup()
 
-                var transportIcon = L.Icon.extend({ //图标初始化
-                    options: {
-                        iconSize: [50, 50], // 图标尺寸
+                        var transportIcon = L.Icon.extend({ //图标初始化
+                            options: {
+                                iconSize: [50, 50], // 图标尺寸
+                            }
+                        })
+
+                        var qd = new transportIcon({
+                            iconUrl: './img/dingw.gif'
+                        })
+
+                        that.LXdhStart.addLayer(L.marker([that.lat, that.lng], {
+                            icon: qd,
+                        }))
+
+                        that.map.addLayer(that.LXdhStart)
+
                     }
                 })
 
-                var qd = new transportIcon({
-                    iconUrl: './img/dingw.gif'
-                })
+                latLng = new qq.maps.LatLng(that.lat, that.lng)
 
-                that.LXdhStart.addLayer(L.marker([that.lat, that.lng], {
-                    icon: qd,
-                }))
-
-                that.map.addLayer(that.LXdhStart)
+                geocoder.getAddress(latLng)
 
             };
 
             function showErr () {
-                //TODO 如果出错了调用此方法 
-            };
+                console.log('定位失败')
+            }
 
             geolocation.getLocation(showPosition, showErr, options)
-        },
+        }
 
     },
-    created () { },
+    created () {
+        var that = this
+        document.addEventListener('UniAppJSBridgeReady', function (e) {
+            uni.getEnv(function (res) {
+                console.log('当前环境:' + JSON.stringify(res))
+            })
+
+            // 向uniapp底座发送消息
+            uni.postMessage({
+                data: that.regionName
+            })
+        })
+    },
     mounted () {
         this.getDataList()
         this.getLocationData()
+
     },
     wacth: {}
 })
\ No newline at end of file

--
Gitblit v1.9.3