# 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信息(默认)1 APP在前台时,每移动distanceFilter的距离返回一次回调2 无论APP在前后台,每移动distanceFilter的距离返回一次回调(注意耗电)} distanceFilter: {Type: String, Default: 10 ,Description: 每移动多少米回调一次定位信息( alwaysAuthorization 为1 或2 时有效,单位为米)} isReqAuthen: { // ^6.4Type: 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
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 没有权限 |