manifest一定要這么設置 H5才能獲取經緯度:(,key需要到官網申請,用https的方式訪問才行。
調取代碼
// #ifdef H5
uni.getLocation({
type: 'gcj02',
success: (res) => {
this.latitude=res.latitude;
this.longitude=res.longitude;
console.log(this.latitude);
console.log(this.longitude);
console.log(res);
// console.log('當前位置的經度:' + res.longitude);
// console.log('當前位置的緯度:' + res.latitude);
}
});