更新获取位置
This commit is contained in:
parent
902224ebf1
commit
d70f6c6f8a
14
App.vue
14
App.vue
@ -91,6 +91,20 @@
|
|||||||
initEvent();
|
initEvent();
|
||||||
// #endif
|
// #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;
|
let that = this;
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
if (HTTP_REQUEST_URL == '') {
|
if (HTTP_REQUEST_URL == '') {
|
||||||
|
@ -17,9 +17,20 @@ export const initEvent = () => {
|
|||||||
console.log('获取定位');
|
console.log('获取定位');
|
||||||
let res = await uniMPgetLocation();
|
let res = await uniMPgetLocation();
|
||||||
console.log(res);
|
console.log(res);
|
||||||
// mp.sendUniMPEvent(ret.fromAppid, 'getLocation', res, (e) => {
|
// plus.geolocation.getCurrentPosition(function(position) {
|
||||||
// console.log('发送成功', e);
|
// 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(
|
mp.sendUniMPEvent(
|
||||||
ret.fromAppid,
|
ret.fromAppid,
|
||||||
'getLocation', {...res},
|
'getLocation', {...res},
|
||||||
|
@ -6,15 +6,17 @@ export const test = ()=>{
|
|||||||
export const uniMPgetLocation = ()=>{
|
export const uniMPgetLocation = ()=>{
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'gcj02',
|
// type: 'gcj02',
|
||||||
geocode: true,
|
// geocode: true,
|
||||||
isHighAccuracy: true,
|
// isHighAccuracy: true,
|
||||||
|
// altitude: true,
|
||||||
|
accuracy: 'best',
|
||||||
success: (res)=> {
|
success: (res)=> {
|
||||||
resolve(res)
|
resolve(res)
|
||||||
},
|
},
|
||||||
fail(e) {
|
fail(e) {
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user