react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

Getting heading value -1 in Geolocation.getCurrentPosition method only in iOS

Open harikanammi opened this issue 6 years ago • 4 comments
trafficstars

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

Simulator Screen Shot - iPhone 6s - 2019-08-08 at 16 59 38

harikanammi avatar Aug 09 '19 06:08 harikanammi

@harikanammi Did you find a solution? I'm having the same issue. Thanks!

sanderwapstra avatar Aug 21 '19 13:08 sanderwapstra

experiencing the same thing here, did anyone find a solution?

stefanoTron avatar Oct 14 '19 10:10 stefanoTron

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

turnipdabeets avatar Dec 21 '19 00:12 turnipdabeets

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.

naftalibeder avatar Nov 03 '22 21:11 naftalibeder