How do I display the "center" button for the user's position? #691
-
Hello, I'd like to know how to display this button please: This button is supposed to do stuff like centring the camera on the user's position, or ask for location permissions and then centre the camera on the user's position. This is what I have tried so far: import { Camera, MapView, UserLocation } from "@maplibre/maplibre-react-native";
export default function CarpiMap() {
return (
<MapView
style={{ flex: 1 }}
mapStyle="https://demotiles.maplibre.org/style.json"
compassEnabled={true}
compassViewPosition={1}
>
<UserLocation
visible={true}
renderMode="normal"
showsUserHeadingIndicator={true}
/>
<Camera followUserLocation={true} />
</MapView>
);
} I tried fiddling with these settings but nothing so far, no button appearing anywhere. The map does show my current location with a blue marker, but not the button that I'm talking about. I have looked at the documentation but I couldn't find anything obvious. Would you be able to help me please? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@JPFrancoia, This is pretty easy to handle outside of the library with react-native views and positioning. Wrap MapView in a react-native View with a |
Beta Was this translation helpful? Give feedback.
-
I see, indirectly my question was "does maplibre-react-native do that out of the box?". With react-map-gl/maplibre (it's for web) I can just use a |
Beta Was this translation helpful? Give feedback.
MapLibre Native doesn't provide such controls and therefore MLRN also doesn't provide such functionality. It's quite easy to implement this yourself in your app.