react-native-geolocation
react-native-geolocation copied to clipboard
Getting heading value -1 in Geolocation.getCurrentPosition method only in iOS
Platforms
iOS
Versions
- react-native-geolocation:1.4.2
- react-native:0.58.4
- react:16.6.3
Description
I am using Geolocation.getCurrentPosition method for getting current latitude and longitude and I am getting heading value as -1 in iOS whereas in android it working fine. How to get the correct heading value to rotate the marker.
Code
Geolocation.getCurrentPosition(info => {
console.log("Geolocation",info)
});
Screenshot

@harikanammi Did you find a solution? I'm having the same issue. Thanks!
experiencing the same thing here, did anyone find a solution?
I believe this only works on a device and not a simulator. Also on the device you need to have the Compass Calibration turned on:
Go to Setting > Privacy > Location Services > System Services > Compass Calibration > Enable
This is because on iOS, heading pulls from CLLocation.course, which refers to "The direction in which the device is traveling". So if the device is not moving along a path, the value will be -1.