[Android] User location heading is not correct
See original GitHub issueBackground
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:
- Created 3 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top GitHub Comments
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!
To add to this with another post, that also takes bearing into account, for the sake of completeness: https://aviation.stackexchange.com/a/8947