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