# getGpsInfo

获取gps信息

# 请求参数

Prop Type Required Default Description
param Object Y {}
属性:
accuracy:{
Type: Number,
Default: 3,
Description: (定位的精确度)
1、低精度,仅用设备定位模式
2、中精度,低功耗定位模式
3、高精度,高精度定位模式

}
alwaysAuthorization:{
Type: Number,
Default: 0,
Description: (是否开启实时定位功能)
0只返回一次GPS信息(默认)
1APP在前台时,每移动distanceFilter的距离返回一次回调
2无论APP在前后台,每移动distanceFilter的距离返回一次回调(注意耗电)

}
distanceFilter:{
Type: String,
Default: 10,
Description: 每移动多少米回调一次定位信息(alwaysAuthorization12时有效,单位为米)
}
isReqAuthen:{ // ^6.4
Type: Boolean,
Default: true,
Description: 当 APP 没有位置权限的时候,是否弹出去设置权限的提示,安卓默认是true
}
请求参数

# 接口调用示例


this.$bridge
    .getGpsInfo(param)
    .then(res => {    
      this.$alert(res)
    })
    .catch(err => {
      this.$toast(err)
    })
// bridge v0.2.3起支持回调函数,回调函数可触发多次
this.$bridge
    .getGpsInfo(
        param,
        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

# 返回参数

  • 成功时返回
Prop Type Default Description
status Number N/A 0 获取GPS成功
province ^5.0.0 String N/A 省名字
city ^5.0.0 String N/A 城市名字
cityCode ^5.0.0 String N/A 城市编码
district ^5.0.0 String N/A 区域名称
longitude String N/A 经度
latitude String N/A 纬度
  • 失败时返回
Prop Type Default Description
errorCode Number N/A -1 没有权限
Last Updated: 10/27/2022, 4:12:24 PM