NativeScript / nativescript-geolocation

Geolocation plugin to use for getting current location, monitor movement, etc
Apache License 2.0
139 stars 76 forks source link

Direction property is always -1 on iOS #209

Closed jammy-git closed 5 years ago

jammy-git commented 5 years ago

I've downloaded the demo app, using demo-vue, changed line 16 in demo-vue/app/components/Home.vue to

<Label :text="item.direction" />

No other code changes from the demo files.

The direction property on iOS (iPhone SE running iOS 12.2) is -1. This seems to be an issue on the simulator too.

I've seen a few other people report this issue both on GitHub and SO but no one seems to have a solution?

jammy-git commented 5 years ago

Just to add to this after doing some more testing last night. It seems it's not always -1, however when a reading finally does come through it's pretty random and seems to bear no resemblance to the actual compass heading at all.

tgpetrov commented 5 years ago

Hi @jammy-git First I'd like to point out that the direction that you are visualising is mapped to the Course Information from the native APIs and not to the Heading. The difference between the two is explained in details here. The initial value of -1 is also expected, as the documentation states that:

When enough location data has been gathered to compute a course, the location manager fills in the speed and course properties of the location object with the appropriate values.

The assignment of the direction property happens here. As you can see, the plugin doesn't do much regarding the direction, it just takes into account the course information that it receives from the native CLLocation object, so any unexpected values seem more likely to be not related to the plugin, but rather to the device's GPS capabilities, the current location's GPS signal, etc.