# getLocation
获取当前坐标。
# 输入
继承标准对象输入,扩展属性描述
| 名称 | 数据类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| params | Object | 否 | 拓展参数对象,详情见params参数说明needBackGroundLocation: 是否后台持续定位。1表示需要后台持续定位 0表示不需要后台持续定位 |
params参数说明:
| 名称 | 数据类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| needBackGroundLocation | int/bool | 否 | 0 | 1表示需要后台持续定位; 0表示不需要后台持续定位 |
| type | string | 否 | baidu | native:原生坐标;baidu:百度坐标 amap:高德坐标(该参数V5.1.5及以上版本才支持) |
# 输出
继承标准对象输出,无扩展属性
# 示例代码
app.getLocation(res => {
bui.alert(JSON.stringify(res, null, 2));
}, error => {
bui.alert(JSON.stringify(error, null, 2));
}, {
needBackGroundLocation: 1
});