uniapp H5定位(踩坑)


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);
}
});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM