question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] User location heading is not correct

See original GitHub issue

Background On Android, the heading property reported by UserLocation.onUpdate is not correct because it is not the direction in which the phone is pointing (as it is implemented on iOS), but it is in fact the user course (the direction in which the device/user is travelling).

This happens because on android the Location.getBearing() is called instead of LocationComponent.getCompassEngine().getLastHeading().

Difference between course and heading It seems that users are confusing and intermixing the terms heading and course, and this difference in value of heading for iOS and Android is a good example of that. A good explanation of the differences between heading and course can be found here: http://www.chrobotics.com/library/heading-course-and-crab-angle

Suggested fix We suggest that we add a new property course on the location.coordinates object. This will have correct/valid values for both iOS and Android.

Since the heading value on Android is wrongly displaying the course (as described above), we suggest that we add a comment to the documentation about this to make users aware of the bug. This is a short term fix to make users aware of it.

To fix the heading bug in Android is a bigger/separate task. We therefore suggest that we create a separate issue and eventually a PR for this in the native Android repository. Once heading is added in the native layer, then we can also correct the heading bug here in react native repository.

We have created a PR to add the course at: https://github.com/react-native-mapbox-gl/maps/pull/1209

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
jaltincommented, Feb 26, 2021

This comment is for anyone stumbling on this issue and want it to be fixed.

In short, to fix the incorrect heading a change is needed in the native mapbox Android project. We have created an issue about this in the native android project (https://github.com/mapbox/mapbox-gl-native-android/issues/652).

It would be great if any of you peeps wanting this to be fixed also comment and/or add positive reactions in that issue to increase the chance of it being noticed by the mapbox native maintainers.

Thx!

1reaction
ferdicuscommented, Feb 12, 2021

To add to this with another post, that also takes bearing into account, for the sake of completeness: https://aviation.stackexchange.com/a/8947

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Android] User location heading is not correct #1213 - GitHub
On Android, the heading property reported by UserLocation.onUpdate is not correct because it is not the direction in which the phone is ...
Read more >
Calculate true heading correctly in android - Stack Overflow
To calculate a heading, you only need the Azimuth. As you have shown, it is values[0] returned from the call to SensorManager.getOrientation.
Read more >
Manage your Android device's location settings - Nexus Help
Choose location settings (Android 9.0) · Open your phone's Settings app. · Tap Security & Location and then Location. · Tap Mode. ·...
Read more >
How to Calibrate a Google Maps App to Be More Accurate
How to calibrate your Google Maps app to give more accurate directions, on iPhone or Android · 1. Open your Settings app and...
Read more >
Location - Android Developers
However, since elapsed realtime is with reference to system boot, it does not make sense to use this value to order or compare...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found