Maps: [Android] User location heading is not correct

Created on 9 Feb 2021  路  5Comments  路  Source: react-native-mapbox-gl/maps

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

Most helpful comment

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!

All 5 comments

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

@ferdicus, we have now added an issue in the v.6 native Android about making the heading public.

Do you have any experience in reqeusting changes in the native layers? And if so, do you know if they tend to respond to these types of requests?

Thx!

@ferdicus, we have now added an issue in the v.6 native Android about making the heading public.

Do you have any experience in reqeusting changes in the native layers? And if so, do you know if they tend to respond to these types of requests?

Thx!

Hey @jaltin, no I do not have much experience with requesting upstream requests myself,
however gathering from the recent changes of the mapbox native sdks I wouldn't hold my breath.

especially now, when they're moving to v10

however gathering from the recent changes of the mapbox native sdks I wouldn't hold my breath.

especially now, when they're moving to v10

@ferdicus Yes that was my thinking/worry too. Thanks for your feedback!

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bllanos picture bllanos  路  3Comments

atomheartother picture atomheartother  路  3Comments

gmaclennan picture gmaclennan  路  3Comments

RichardLindhout picture RichardLindhout  路  4Comments

alexisrougnant picture alexisrougnant  路  3Comments