# getGPSInfo ^6.8

获取gps定位信息

# 请求参数

Prop Type Default Comment
isReqAuthen Boolean N/A ^6.4(仅安卓)当APP没有位置权限的时候,是否弹出去设置权限的提示,安卓默认是true
distanceFilter Number N/A /alwaysAuthorization为1或2时有效,每移动多少米回调一次定位信息,默认10米
alwaysAuthorization Number N/A 是否开启实时定位功能,0: 只返回一次GPS信息(默认),1:APP在前台时,每移动distanceFilter的距离返回一次回调。2:无论APP在前后台,每移动distanceFilter的距离返回一次回调(注意耗电)
accuracy Number N/A 定位的精确度

# 接口调用示例

const params = {
  accuracy: 3,
  alwaysAuthorization: 1,
  distanceFilter: 12,
  isReqAuthen: true,
}
this.$bridge
  .getGPSInfo(params)
  .then(res => {
    this.$alert(res)
  })
  .catch(err => {
    this.$toast(err)
  })
// v0.3.5 支持回调函数,可重复触发执行
this.$bridge
  .getGPSInfo(
    params,
    res => {
      this.$alert(res)
    },
    err => {
      this.$toast(err)
    }
  )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

# 返回参数

  • 成功时返回
Prop Type Default Description
status Number N/A 0获取GPS成功
cityCode String N/A 城市编号, (^5.0.0)
city String N/A 城市名字,(^5.0.0)
longitude Number N/A 经度
district String N/A 区域名字 (^5.0.0)
latitude Number N/A 纬度
province String N/A 省名字,(^5.0.0)
  • 失败时返回
Prop Type Default Description
errorCode Number N/A 0 成功,-1 没有权限
更新时间: 10/27/2022, 5:05:59 PM