UserLocation does not use high accuracy on Android 12
See original GitHub issueDescribe the bug
After users have upgraded to Android 12 the UserLocation component no longer appears to use high accuracy mode. This is indicated by the users location darting around (as opposed to being true to their actual location) and the location status icon is no longer shown. On Android 11 the location status icon was shown regardless.
Using React Native Geolocation with a watch and high accuracy mode turned on corrects to the expected behaviour showing an accurate location and the location status icon.
To Reproduce
Use a UserLocation component on any Android 12 device. I have been using a S20 FE and an S21 to confirm (Android 12 vs still on Android 11)
Example:
import React from 'react';
import {
MapView,
ShapeSource,
LineLayer,
Camera,
UserLocation,
} from '@rnmapbox/maps';
class BugReportExample extends React.Component {
render() {
return (
<MapView style={{flex: 1}}>
<UserLocation />
</MapView>
);
}
}
Expected behavior
The users location is shown correctly and the location status icon is shown indicating use of high accuracy location.
Actual behavior
Users location darts around and no location status icon is shown.
Screenshots
Versions (please complete the following information):
- Platform: Android
- Platform OS: Android 12
- Device: Android S20 FE
- Emulator/ Simulator: no
- Dev OS: MacOS 12.1
- @rnmapbox/maps Version 8.4.0
- Mapbox GL version 9.7.1
- React Native Version 0.66.4
Additional context
N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Solution is described https://github.com/mapbox/mapbox-gl-native-android/issues/730 and https://docs.mapbox.com/android/maps/guides/user-location/#location-provider TLDR add following into build.gradle
@RobertSasak I use the
MapboxGL.requestAndroidLocationPermissions();
function on boot of my application to call the correct permissions. This includes both required permission calls as needed on Android 12.