mc.getLocation(Object object)

获取当前的地理位置、速度。当用户离开应用后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。

Object object 参数

属性 类型 默认值 必填 说明 最低版本
type String wgs84 wgs84 返回 gps 坐标
altitude Boolean false 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
isHighAccuracy Boolean false 开启高精度定位
highAccuracyExpireTime Number 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)  

Object.success(Object res) 回调函数

属性 类型 说明 最低版本
latitude Number 纬度,范围为 -90~90,负数表示南纬
longitude Number 经度,范围为 -180~180,负数表示西经
speed Number 速度,单位 m/s
accuracy Number 位置的精确度
altitude Number 高度,单位 m
verticalAccuracy Number 垂直精度,单位 m(Android 无法获取,返回 0)
horizontalAccuracy Number 水平精度,单位 m  

示例代码:

mc.getLocation({
  success: function(res) {
    console.log(res.latitude);
    console.log(res.longitude);
    console.log(res.speed);
  }
})

results matching ""

    No results matching ""

    results matching ""

      No results matching ""