微信小程序获取及选择位置
- 获取当前的地理位置、速度
wx.getLocation({
type: "wgs84", //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 gcj02在android机上有bug,无法选择位置
success(res) {
}
});
- 打开地图选择位置
wx.chooseLocation({
success(res) {
let name = res.name; //名称
let address = res.address; //详细地址
let longitude = res.longitude;//经度
let latitude = res.latitude;//纬度
fail: function(info){
//失败回调
console.log(info)
}
})
}
});
- 使用微信内置地图查看位置
openLocation(item){
let longitude = item.longitude;
let latitude = item.latitude;
wx.openLocation({
lati