diff --git a/App.vue b/App.vue index 3ec68f2..842c470 100644 --- a/App.vue +++ b/App.vue @@ -91,6 +91,20 @@ initEvent(); // #endif + uni.getLocation({ + // type: 'gcj02', + // geocode: true, + // isHighAccuracy: true, + // altitude: true, + accuracy: 'best', + success: (res)=> { + console.log(res); + }, + fail(e) { + console.log(e); + } + }); + let that = this; // #ifdef MP if (HTTP_REQUEST_URL == '') { diff --git a/utils/uniMPevent.js b/utils/uniMPevent.js index eea9892..19262b2 100644 --- a/utils/uniMPevent.js +++ b/utils/uniMPevent.js @@ -17,9 +17,20 @@ export const initEvent = () => { console.log('获取定位'); let res = await uniMPgetLocation(); console.log(res); - // mp.sendUniMPEvent(ret.fromAppid, 'getLocation', res, (e) => { - // console.log('发送成功', e); - // }) + // plus.geolocation.getCurrentPosition(function(position) { + // console.log('经度:' + position.coords.longitude); + // console.log('纬度:' + position.coords.latitude); + // // that.markers[1].latitude = position.coords.longitude; + // // that.markers[1].longitude = position.coords.longitude; + // mp.sendUniMPEvent( + // ret.fromAppid, + // 'getLocation', {...position.coords}, + // (ret) => { + // console.log('Host sendEvent: ' + JSON.stringify(ret)); + // }); + // }, function(error) { + // console.error('获取位置失败:', error.message); + // }, {provider:'gps'}); mp.sendUniMPEvent( ret.fromAppid, 'getLocation', {...res}, diff --git a/utils/uniMPfunction.js b/utils/uniMPfunction.js index cdce7d1..32184bc 100644 --- a/utils/uniMPfunction.js +++ b/utils/uniMPfunction.js @@ -6,15 +6,17 @@ export const test = ()=>{ export const uniMPgetLocation = ()=>{ return new Promise((resolve, reject)=>{ uni.getLocation({ - type: 'gcj02', - geocode: true, - isHighAccuracy: true, + // type: 'gcj02', + // geocode: true, + // isHighAccuracy: true, + // altitude: true, + accuracy: 'best', success: (res)=> { resolve(res) }, - fail(e) { - reject(e) - } + fail(e) { + reject(e) + } }); }) } \ No newline at end of file