# wx.onLocationChange


小程序框架2.0.7版本开始支持

监听实时地理位置变化事件,需结合 wx.startLocationUpdate使用

# 参数

# function callback

实时地理位置变化事件的回调函数

# 回调参数

Object res

属性 类型 说明
latitude string 纬度
longitude string 经度
altitude string 海拔
country string 国家
city string 城市
province string 省
district string 区
street string 街道
streetNumber string 街道号码
adCode string 邮编
type string 定位类型

# 示例代码

let callback = (data) => {
  console.log(data)
}
wx.onLocationChange(callback)

# 注意事项

1.wgs84坐标类型只返回经纬度,bd09ll、gcj02坐标类型需开启高精度模式,才能获取其他信息。

2.iOS14以上用户可以控制开启应用定位高精度,未开启高精度时,位置信息会有偏差。

3.小程序调用的App需要集成对应的插件,具体参照App文档。

4.安卓断网情况下任何定位方式都不可用,ios可用wgs84。