微信小程序-位置坐标

时间:2023-03-09 13:28:00
微信小程序-位置坐标

wx.getLocation(OBJECT)

获取当前的地理位置、速度。

OBJECT参数说明:

微信小程序-位置坐标

success返回参数说明:

微信小程序-位置坐标

示例代码:

wx.getLocation({
  type: 'wgs84',
  success: function(res) {
    var latitude = res.latitude
    var longitude = res.longitude
    var speed = res.speed
    var accuracy = res.accuracy
  }
})

wx.chooseLocation(OBJECT)

打开地图选择位置

OBJECT参数说明:

微信小程序-位置坐标

success返回参数说明:

微信小程序-位置坐标

wx.openLocation(OBJECT)

​ 使用微信内置地图查看位置

OBEJCT参数说明:

微信小程序-位置坐标

示例代码:

wx.getLocation({
  type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  success: function(res) {
    var latitude = res.latitude
    var longitude = res.longitude
    wx.openLocation({
      latitude: latitude,
      longitude: longitude,
      scale:
    })
  }
})