本文實(shí)例講述了微信小程序在地圖選擇地址并返回經(jīng)緯度功能。分享給大家供大家參考,具體如下:
微信小程序的地址管理中,經(jīng)常需要獲取地址的詳細(xì)地址信息和地址經(jīng)緯度信息
wxml文件部分代碼:
<button bindtap="mapView" style="margin:10px">查看地圖</button>
js文件主要功能代碼:
mapView:function(){  var that = this  wx.chooseLocation({   success: function (res) {    // success    console.log(res,"location")    that.setData({     hasLocation: true,     location: {      longitude: res.longitude,      latitude: res.latitude     },     detail_info: res.address,     wd: res.latitude,     jd: res.longitude    })   },   fail: function () {    // fail   },   complete: function () {    // complete   }  })}運(yùn)行效果:

希望本文所述對(duì)大家微信小程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注