Reputation: 7898
This is my first time working with Mapbox I'm using the latest recommended v10 (10.0.0-beta.59) and I'm not able to see the user location marker on Android.
In AndroidManifest.xml
I've added the permissions:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Then in the screen where I have the map I'm displaying the user locations like:
import MapboxGL from "@rnmapbox/maps";
//... other code
async function hasLocationPermission() {
if (Platform.OS === 'ios' || (Platform.OS === 'android' && Platform.Version < 23)) {
return true;
}
const isGranted = await MapboxGL.requestAndroidLocationPermissions();
return isGranted;
}
useEffect(() => {
const task = async () => {
const per = await hasLocationPermission()
setPermission(per)
}
task()
}, [false])
// ... other code
<MapboxGL.MapView style={styles.map} compassEnabled={true} logoEnabled={false}>
<MapboxGL.UserLocation
androidRenderMode={'compass'}
visible={true}
onUpdate={(location) => { console.log("location: ", location) }}
showsUserHeadingIndicator={true}
/>
<MapboxGL.Camera
zoomLevel={zoom}
followUserMode={'compass'}
followUserLocation />
</MapboxGL.MapView>
//... rest of the code
When I run the app, I can see the user location marker on the iOS simulator. I'm running the Android app on the android physical device, and it asked me for location permission at the start and then nothing. I do see locationManager Error: [Error: Last location unavailable]
on but I'm not using the last location and plus I'm on the v10 version and that too for react-native.
Upvotes: 1
Views: 916