maps: [Bug]: UserLocation doesn't work with other GeoLocation Services (Android)
Mapbox Implementation
Mapbox
Mapbox Version
10
Platform
Android
@rnmapbox/maps version
10.0.0-beta.11
Standalone component to reproduce
import { StyleSheet, View ,Text,PermissionsAndroid, SafeAreaView} from 'react-native';
import Mapbox, {UserLocationRenderMode} from '@rnmapbox/maps'
import { useEffect, useState } from "react";
export function Map(){
const [location,setLocation] = useState(null);
const [hasLocationPermissions,sethasLocationPermissions] = useState(false)
const requestLocationPermission = async () =>
{
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
sethasLocationPermissions(true)
console.log("You can use the location")
alert("You can use the location");
} else {
console.log("location permission denied")
alert("Location permission denied");
}
} catch (err) {
console.warn(err)
}
}
useEffect(()=>{
requestLocationPermission()
},[])
return(
<SafeAreaView style={styles.container}>
<Mapbox.MapView style={styles.map} >
<Mapbox.PointAnnotation
draggable={true}
onDragEnd={feature => {
console.log(feature);
setLocation({
latitude: feature.geometry.coordinates[1],
longitude: feature.geometry.coordinates[0],
});
}}
coordinate={ [
-1.510311133796023,
53.816142903704616
]}
>
<View style={{
height: 30,
width: 30,
backgroundColor: '#00cccc',
borderRadius: 50,
borderColor: '#fff',
borderWidth: 3
}} />
</Mapbox.PointAnnotation>
<Mapbox.UserLocation
visible={true}
androidRenderMode={'compass'}
showsUserHeadingIndicator={true}
onUpdate={newLocation => {
console.log(newLocation)
}}
/>
</Mapbox.MapView>
</SafeAreaView>
)
}
Observed behavior and steps to reproduce
This started when i switched to mac os, i have a project with rnmapbox and react-native-geolocation-service in linux android was working fine with both i could get updates from UserLocation but in mac os that doesn’t work anymore so i tried to figure out what was wrong, i started a new project and i could get update locations without react-native-geolocation-service installed, so i installed another lib @react-native-community/geolocation and still happens the same the UserLocation didn’t work anymore, i only can work with UserLocation on android without any geolocation lib.
Expected behavior
No response
Notes / preliminary analysis
No response
Additional links and references
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 28 (6 by maintainers)
Throughout this issue there are quite a few different/unclear problems stated. Therefore it’s hard to determine, who is confirming which problem. I figured at least one specific case described by @FrancoisVA in our app too:
To further clarify, the puck on the map does not update for
normalrender mode (either custom children or the default from rnmapbox). Usingnativerender mode will give a moving puck. For both render modesonUpdateis only triggered once. I’m on the#mainBranch equivalent tov10.0.7-rc.1.This occurs due to no
displacementbeeing passed. So anyone who’s experiencing theaforementionedproblem, please try the following:Please give feedback 👍 👎 if this workaround works (only if you are experiencing this very same problem). You should be seeing a moving puck and getting “location changed” regularly, if you are simulating/moving your location.
@mfazekas sadly I’m still not able to reproduce the bug in the example. I can only recreate it in our expo project. Through prebuild I added error logging to the
LocationManageronFailurewhich gave the following error:So under some circumstances when displacement is passed as
-1.0Mapbox SDK throws an error.I’m having the same issue, but adding
useEffect(() => {MapboxGL.locationManager.start()},[]}doesn’t seem to do the trick for me.Downgraded to
10.0.0-beta.70and then it works again.This is also a problem I have been seeing intermittently for more than a year with our build. No one has been able to fix it so far; currently working with someone to try to build a work around for this case. Any help in solving this would be amazing for us!
Had the issue and setting minDisplacement={0} solved it. In doc, it is still said that default is 0 !
@FrancoisVA Is working for me now the 10.0.0-beta.70
@mfazekas I tried to do that, and the problem persists i updated to /maps-10.0.0-rc.8 and on ios i was unable to install " rnmapbox-maps (from
../node_modules/@rnmapbox/maps) was resolved to 10.0.0-rc.8, which depends on MapboxMaps (~> 10.12.0)"(update): -> i could resolve the problem of ios by pod update.
-> idk if the problem is cache of project or not, but i already removed the node modules, yarn clean cache, watchman clean and still persists
->Another issue i spotted it is when we open the app for the first time on android and i ask for permission the user location throws an error even if i accept the permisions, that isue doesn’t occur on ios.
@0xcD3v Sorry it’s a community project, with limited resources.