篇首语:本文由小编为大家整理,主要介绍了微信小程序实战——获取用户地理位置信息相关的知识,希望对你有一定的参考价值。
app.json
开通获取用户地理位置信息访问权限
"permission":
"scope.userLocation":
"desc": "获取你的位置信息"
,
pages\index\index.wxml
经度:location.latitude 纬度:location.longitude
pages\index\index.js
Page(
data:
location: null
,
getLocation: function ()
wx.getLocation(
type: wgs84,
success: (res) =>
this.setData(
location:
latitude: res.latitude, // 纬度
longitude: res.longitude // 经度
)
)
,
)
最终效果
点击获取当前地理位置按钮
以上是关于微信小程序实战——获取用户地理位置信息的主要内容,如果未能解决你的问题,请参考以下文章