'Why expo-location getCurrentPositionAsync heading returns -1 on ios?
The getCurrentPositionAsync function returns the speed and heading values of -1. It says in the document that if location permissions are not open, it can return as -1, but the speed and heading return -1 even though my location permission is open. What is the reason? Thanks in advance.
const { status } = await Location.getForegroundPermissionsAsync();
const permission = await Location.getBackgroundPermissionsAsync();
if (status === "granted") {
const location = await Location.getCurrentPositionAsync();
}
Object {
"coords": Object {
"accuracy": 13.815849315805039,
"altitude": 108.1436996459961,
"altitudeAccuracy": 14.495187759399414,
"heading": -1,
"latitude": 52.205276,
"longitude": 0.119167,
"speed": -1,
},
"timestamp": 1639056231575.1208,
}
Solution 1:[1]
(Expo-Location)
Please Take Permission Before access location.
Below Snippet Code you can try..
let { status } = await Location.requestForegroundPermissionsAsync();
if (status == 'granted') {
let location = await Location.getCurrentPositionAsync({});
console.log("Loc ",location);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vijay Sahani |
