UserLocation component displays the user’s current location on the map with customizable appearance and behavior.
Basic Usage
Props
Android-only render mode for the location indicator.
normal: Simple circlecompass: Triangle with headinggps: Large arrow
Whether the location icon is animated between updates.
Custom location icon using Mapbox GL Native components. When provided, replaces the default location indicator.
Minimum distance (in meters) the device must move before the GPS location is updated.
Callback function triggered when the location icon is pressed.
Callback function triggered when the location is updated.
Deprecated: Use
LocationPuck component instead of UserLocationRenderMode.Native.Specifies which render mode to use:UserLocationRenderMode.Normal: Custom React Native renderingUserLocationRenderMode.Native: Native platform rendering
Request “always” location permission to track location even when the app is in the background.Platform: iOS only
Show or hide a small arrow indicating the direction the device is pointing relative to north.
Controls whether the location icon is visible on the map.
Types
Location
Location coordinates object.
Unix timestamp (in milliseconds) when the location was determined.
Coordinates
The latitude in degrees.
The longitude in degrees.
The heading (measured in degrees) relative to true north. Indicates the direction the device is pointing to (compass value).Note: On Android, this may incorrectly report the course value. See issue #1213.
The direction in which the device is traveling, measured in degrees relative to due north. Different from heading - this is the actual direction of movement.
The instantaneous speed of the device, measured in meters per second.
The radius of uncertainty for the location, measured in meters.
The altitude, measured in meters.
Methods
setLocationManager
onUpdate or visible props are set.
true to start listening, false to stop.needsLocationManagerRunning
Examples
Basic User Location
With Location Updates
Custom Location Indicator
With Minimum Displacement
See Also
- LocationPuck - Modern native location puck component
- CustomLocationProvider - Provide custom location data
- locationManager - Location manager singleton