//预约到店 获取当前经纬度
getLocation() {
const that = this;
uni.authorize({
scope: 'scope.userLocation',
geocode: true,
success() { // 允许授权
// that.getLocationInfo();
uni.getLocation({ //获取经纬度信息
type: 'wgs84',
success(res) {
let latitude, longitude;
latitude = res.latitude.toString();
longitude = res.longitude.toString();
}
});
},
fail() { // 拒绝授权
// that.openConfirm();
console.log("你拒绝了授权,无法获得周边信息")
}
})
},
微信小程序获取当前经纬度
于 2021-11-29 19:19:55 首次发布
该篇博客详细介绍了如何在uni-app中实现用户位置授权和获取经纬度信息的过程。通过uni.authorize进行权限请求,然后利用uni.getLocation获取wgs84坐标系下的经纬度,为应用提供获取用户当前位置的能力。
1万+

被折叠的 条评论
为什么被折叠?



