微信小程序-地图导航
功能描述:发布信息的时候选择位置;详情页展示的时候展示位置名称并且可以导航到该位置。
1)选择位置
chooseLocation: function () {
let that = this;
wx.chooseLocation({
success: function (res) {
that.setData({
osscation_address: res.address,//详细地址
addressName: res.name,//位置名称
latAndLong: [{ 'latitude': res.latitude, 'longitude': res.longitude }]//经纬度
})
}
})
}
2)展示地址名称
自行根据接口在指定字段显示地址名称。
3)导航到展示的地址
也是根据接口拿到该地址的经纬度信息。
wx.openLocation({
name:'香洲区政府',
address:'广东省珠海市香洲区翠景路99号',
latitude: 22.26666,
longitude: 113.51342,
scale: 18//缩放级别
})