-
Hello guys, I'm trying to implement a center to user's position button using the flyTo method from MapboxGL.Camera, but nothing happens. Is this know as a bug or maybe is it just a wrong implementation ? Thanks! Simple example code: const MapScreen: React.FC<MapScreenProps> = () => {
const userPosition = [-46.7003, -23.5366];
const cameraRef = useRef<MapboxGL.Camera | null>(null);
const centerMapOnUser = (position: GeoJSON.Position) => {
if (cameraRef.current) {
cameraRef.current.flyTo(position, 1000);
}
};
return (
<View style={styles.viewContainer}>
<MapboxGL.MapView
style={styles.map}
>
<MapboxGL.UserLocation
visible
androidRenderMode="compass"
showsUserHeadingIndicator
animated
/>
<MapboxGL.Camera
ref={cameraRef}
zoomLevel={16}
centerCoordinate={userPosition}
followUserLocation
animationMode="flyTo"
animationDuration={0}
/>
</MapboxGL.MapView>
<IconButton
style={styles.centerButton}
icon={CenterMapIcon}
onPress={() => centerMapOnUser(userPosition)}
/>
</View>
);
}; |
Beta Was this translation helpful? Give feedback.
Answered by
ferdicus
Jun 23, 2021
Replies: 2 comments 4 replies
-
Camera commands are disabled when you enable |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Drealler
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Camera commands are disabled when you enable
followUserLocation