本文實例講述了微信小程序實現獲取自己所處位置的經緯度坐標功能。分享給大家供大家參考,具體如下:
1、效果展示
2、關鍵代碼
index.wxml布局文件代碼
<view>緯度:{{latitude}}</view><view>經度:{{longitude}}</view>
index.js邏輯文件代碼
Page({ data: { latitude:'', longitude:'' }, onLoad: function () { var that=this; wx.getLocation({ type: 'wgs84', success: function(res) { that.setData({ latitude:res.latitude, longitude:res.longitude }) } }) }})
3、完整實例代碼點擊此處本站下載。
希望本文所述對大家微信小程序開發有所幫助。
新聞熱點
疑難解答