app.json配置
"requiredPrivateInfos": [
"getLocation"
],
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
}
页面调用
wx.getLocation({
type: 'wgs84',
success (res) {
console.log(res);
const longitude = res.longitude; // 经度
const latitude = res.latitude; // 纬度
const speed = res.speed;
const accuracy = res.accuracy;
}
})