diff --git a/pages/index/index.vue b/pages/index/index.vue index d73f72f..143b7f5 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -122,12 +122,13 @@ if (navigator.geolocation) { this.watchId = navigator.geolocation.watchPosition( (position) => { - const coords = position.coords; - const [gcj02Lng, gcj02Lat] = this.wgs84ToGcj02(coords.longitude, coords.latitude); + let coords = position.coords; + let [gcj02Lng, gcj02Lat] = this.wgs84ToGcj02(coords.longitude, coords.latitude); + console.log('自身坐标',gcj02Lat,gcj02Lng) // 计算用户与每个打卡点的距离,找出最近的打卡点 let minDistance = Infinity; let nearestIndex = null; - this.fenceCenter.forEach(item => { + this.fenceCenter.forEach((item,index) => { const distance = this.calculateDistance(item.latitude,item.longitude, gcj02Lat, gcj02Lng) console.log(distance) if (distance < minDistance) { diff --git a/unpackage/dist/build/web/index.html b/unpackage/dist/build/web/index.html index 3a5d9d9..e9ca8e7 100644 --- a/unpackage/dist/build/web/index.html +++ b/unpackage/dist/build/web/index.html @@ -1,2 +1,2 @@