Describe the bug
Using does not cause android camera to follow
To Reproduce
Create a map view, set camera
Expected behavior
The map's camera should follow my current location.
Screenshots
Versions (please complete the following information):
Additional context
Adding a general comment here and words of advice then closing issue.
Android is particularly sensitive to when the map moves which can break follow settings. If you having issues around map position, headings, pitches, follow modes, etc... I suggest you start with assessing renders, interactions, and when props could be updating.
Also suggest stripping down an empty map and simplifying your state to make sure what you are running into is actually a bug. As of this writing the library has been going through a lot of changes and what was previous working code had stopped working with an update.
Lastly, using the following callback seems to be essential if you are managing a complex camera state with a follow on/off toggle. Basically, if the map moves, your component props & the underlying camera native props will get out of sync. This allows you to stay in sync.
onUserTrackingModeChange = event => {
const followUserLocation = event.nativeEvent.payload.followUserLocation
const followUserMode = event.nativeEvent.payload.followUserMode
}
I was able to get rid of the issue by setting the followUserLocation property to a state variable that is false by default. When the map is fully rendered with my current zoom and coordinates, I set the followUserLocation state variable to true. Seems to work well so far.
state = {
followUserLocation: false,
}
<MapboxGL.MapView
style={styles.map}
onDidFinishRenderingMapFully={(r) => {
this.setState({followUserLocation: true})
}}
>
<MapboxGL.Camera
zoomLevel={16}
followZoomLevel={16}
followUserLocation={this.state.followUserLocation}
followUserMode={MapboxGL.UserTrackingModes.FollowWithCourse}
/>
</MapboxGL.MapView>
@grant1842 perfect it works thanks!!!
Most helpful comment
I was able to get rid of the issue by setting the followUserLocation property to a state variable that is false by default. When the map is fully rendered with my current zoom and coordinates, I set the followUserLocation state variable to true. Seems to work well so far.