# getLocation
有权限前提下获取当前经纬度
# 调用方式
getLocation(params)
1
返回 Promise,使用 then/catch 或 await 处理结果。 接收单个业务参数;是否需要传参按下方参数表约定,无业务参数时可省略。具体字段及返回数据由宿主原生约定。
# 请求参数
参数对象字段由宿主约定;调用签名见上方。
# 接口调用示例
this.$bridge.getLocation().then((res) => {
this.$bridge.toast(res)
}).catch((err) => {
this.$bridge.toast(err)
});
1
2
3
4
5
2
3
4
5
# 返回参数
返回 Promise;原生返回数据的字段由宿主决定,当前 JS 封装未限定完整结构。
# 接口返回示例
- 成功
| Prop | type |
|---|---|
| longitude | Number |
| latitude | Number |
{
"longitude":113.11998755893343,
"latitude":22.971706948510718
}
1
2
3
4
2
3
4
- 失败
{
"msg": "未能完成操作。(kCLErrorDomain错误1。)",
"code": "-4"
}
1
2
3
4
2
3
4