已经进行ohos.permission.LOCATION和ohos.permission.APPROXIMATELY\_LOCATION 用户授权申请,并同意授权,但是获取位置信息报错。
报错信息:
geoLocationManager promise, getCurrentLocation: error={"code":3301200,"message":"BussinessError 3301200: Failed to obtain the geographical location."}
获取位置信息方法:
let requestInfo: geoLocationManager.LocationRequest = {
'priority': geoLocationManager.LocationRequestPriority.FIRST_FIX,
'scenario': geoLocationManager.LocationRequestScenario.UNSET,
'timeInterval': 1,
'distanceInterval': 0,
'maxAccuracy': 0
};
geoLocationManager.getCurrentLocation(requestInfo).then((result) => {
console.log('geoLocationManager current location: ' + JSON.stringify(result));
}).catch((error: number) => {
console.log('geoLocationManager promise, getCurrentLocation: error=' + JSON.stringify(error));
});
可以参考下述demo:
Index页面:
module.json5页面: