小程序wx.chooseLocation地圖選點確認地址
/**
* 生命周期函數--監聽頁面加載
*/
onLoad: function (options) {
console.log(options);
if (options.jumpUrl){
wx.chooseLocation({
success: function (res) {
let str = `${options.jumpUrl}&latitude=${res.latitude}&longitude=${res.longitude}&address=${res.address}`
wx.redirectTo({
url: `../../webView/webView?s=map&str=${encodeURIComponent(str)}`
})
}
})
}
},
前沿 :小程序選擇地圖,上述功能是別的頁面進來會傳url地址,onLoad函數
wx.chooseLocation 選擇后會有經度緯度,和詳細地址參數,返回給webView頁面,並把參數放在str 對應上。
一、微信小程序位置接口wx.chooseLocation
本接口使用簡單,用戶用戶通過騰訊地圖選擇一個位置。
本接口能獲得選擇位置的簡稱,全稱,以及坐標。
//選擇地址
wx.chooseLocation({
success: function(res) {
console.info(res);
},
})

容易混淆的接口wx.chooseAddress 本接口用於獲取用戶的收獲地址信息。
