找出微信小程序获取经纬度代码片段
时间: 2023-06-28 09:10:57 浏览: 233
以下是微信小程序获取经纬度的代码片段:
```
wx.getLocation({
type: 'wgs84',
success(res) {
const latitude = res.latitude // 纬度
const longitude = res.longitude // 经度
}
})
```
其中,`wx.getLocation` 是微信小程序提供的获取地理位置信息的 API,`type: 'wgs84'` 表示获取的坐标系为 WGS84,可以直接使用在地图上;`res.latitude` 和 `res.longitude` 分别表示获取到的经纬度信息。
阅读全文
相关推荐












