通过wx.getLocation获取当前的位置,但是返回值中altitude一直显示为0,是什么原因呢?
wx.getLocation({
type: 'gcj02',
altitude: true,
isHighAccuracy:true,
success: (res) => {
that.setData({
latitude: res.latitude,
longitude: res.longitude,
speed: res.speed,
accuracy: res.accuracy
})
qqmapsdk.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
},
success: function (res) {
// console.log(res)
that.setData({
district:res.result.address_component.district,
position:res.result.address_component.street_number
})
}
})
},
});
查看一下手机定位服务是否打开了,在重试看看。
调用该接口前有进行用户授权吗?
加入下面代码试试。
"permission": { "scope.userLocation": { "desc": "您的位置信息将用于寻找附近的检测点" } }
https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html
请问楼主解决了吗?