The User Location feature allows you to track and display the user’s current location on the map. You can customize the appearance, listen to location updates, and control the tracking behavior.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rnmapbox/maps/llms.txt
Use this file to discover all available pages before exploring further.
Components
There are two main ways to display user location:- UserLocation - Customizable React component with full control over appearance
- LocationPuck - Native location puck with optimized performance
Basic Usage
UserLocation Component
TheUserLocation component provides a customizable way to display the user’s location with full React Native rendering capabilities.
Props
| Prop | Type | Description |
|---|---|---|
visible | boolean | Whether the location icon is visible. Default: true |
animated | boolean | Whether location icon is animated between updates. Default: true |
onUpdate | (location: Location) => void | Callback triggered on location update |
onPress | () => void | Callback triggered when location icon is pressed |
minDisplacement | number | Minimum movement in meters before GPS location is updated. Default: 0 |
showsUserHeadingIndicator | boolean | Show arrow indicating device direction. Default: false |
renderMode | UserLocationRenderMode | Render mode: 'normal' or 'native'. Default: 'normal' |
requestsAlwaysUse | boolean | Request always location permission (iOS only) |
androidRenderMode | 'normal' | 'compass' | 'gps' | Android-specific render mode |
children | ReactElement | Custom location icon components |
Tracking Location Updates
Listen to location changes using theonUpdate callback:
Setting Minimum Displacement
Control how often location updates are triggered:Setting a higher
minDisplacement value reduces battery usage by decreasing the frequency of location updates.LocationPuck Component
For better performance with native rendering, useLocationPuck:
LocationPuck Props
| Prop | Type | Description |
|---|---|---|
topImage | string | Name of image to use as the top layer |
bearingImage | string | Image shown when bearing is enabled |
shadowImage | string | Shadow image below the puck |
visible | boolean | Whether the puck is visible |
pulsing | { isEnabled: boolean, color: string, radius: number } | Pulsing animation configuration |
scale | Expression | Scale expression based on zoom level |
puckBearing | 'heading' | 'course' | Type of bearing to display |
puckBearingEnabled | boolean | Enable bearing indicator |
Custom Location Icon
Customize the appearance by passing custom children:Following User Location
Combine withCamera to follow the user’s location:
User Tracking Modes
| Mode | Description |
|---|---|
UserTrackingMode.Follow | Camera follows user location |
UserTrackingMode.FollowWithHeading | Camera follows location and rotates to match device heading |
UserTrackingMode.FollowWithCourse | Camera follows location and rotates to match movement direction |
Platform-Specific Features
iOS
Always Location Permission:Android
Render Modes:normal- Simple circlecompass- Triangle with heading indicatorgps- Large arrow shape
Performance Considerations
- Use
LocationPuckfor better performance when you don’t need custom React Native views - Set appropriate
minDisplacementto reduce update frequency - Consider using
UserLocationRenderMode.Nativefor optimal performance
Permissions
Ensure you have location permissions configured: iOS (Info.plist):Reference
- Source:
src/components/UserLocation.tsx:1 - Source:
src/components/LocationPuck.tsx:1 - Location Manager:
src/modules/location/locationManager.ts:1