import { Camera } from '@rnmapbox/maps';
Camera
Controls the perspective from which the user sees the map.
To use imperative methods, pass in a ref object:
const camera = useRef<Camera>(null);
useEffect(() => {
camera.current?.setCamera({
centerCoordinate: [lon, lat],
});
}, []);
return (
<Camera ref={camera} />
);
literal
Allows static check of the data type. For internal use only.
Position
The location on which the map should center.
intersection
The corners of a box around which the map should bound. Contains padding props for backwards
compatibility; the root padding
prop should be used instead.
number
The heading (orientation) of the map.
number
The pitch of the map.
number
The zoom level of the map.
type Padding = {
paddingLeft: number; /* Left padding in points */
paddingRight: number; /* Right padding in points */
paddingTop: number; /* Top padding in points */
paddingBottom: number; /* Bottom padding in points */
}
The viewport padding in points.
number
The duration the map takes to animate to a new configuration.
| 'flyTo'
| 'easeTo'
| 'linearTo'
| 'moveTo'
| 'none'
The easing or path the camera uses to animate to a new configuration.
boolean
Whether the map orientation follows the user location.
UserTrackingMode
The mode used to track the user location on the map.
number
The zoom level used when following the user location.
number
The pitch used when following the user location.
number
The heading used when following the user location.
Partial
The padding used to position the user location when following.
number
The lowest allowed zoom level.
number
The highest allowed zoom level.
type MaxBounds = {
ne: Position; /* FIX ME NO DESCRIPTION */
sw: Position; /* FIX ME NO DESCRIPTION */
}
The corners of a box defining the limits of where the camera can pan or zoom.
type DefaultSettings = {
type: literal; /* Allows static check of the data type. For internal use only. */
centerCoordinate: Position; /* The location on which the map should center. */
bounds: intersection; /* The corners of a box around which the map should bound. Contains padding props for backwards
compatibility; the root `padding` prop should be used instead. */
heading: number; /* The heading (orientation) of the map. */
pitch: number; /* The pitch of the map. */
zoomLevel: number; /* The zoom level of the map. */
padding: signature; /* The viewport padding in points. */
animationDuration: number; /* The duration the map takes to animate to a new configuration. */
animationMode: union; /* The easing or path the camera uses to animate to a new configuration. */
}
The configuration that the camera falls back on, if no other values are specified.
boolean
Whether the camera should send any configuration to the native module. Prevents unnecessary tile
fetching and improves performance when the map is not visible. Defaults to true
.
string | number
Any arbitrary primitive value that, when changed, causes the camera to retry moving to its target configuration. (Not yet implemented.)
func
Executes when user tracking mode changes.
DEPRECATED use Viewport#onStatusChanged instead.
signature:(event:MapboxGLEvent) => void
Sets any camera properties, with default fallbacks if unspecified.
Name | Type | Required | Description |
---|
camera.current?.setCamera({
centerCoordinate: [lon, lat],
});
Set the camera position to enclose the provided bounds, with optional
padding and duration.
Name | Type | Required | Description |
---|
camera.fitBounds([lon, lat], [lon, lat]);
camera.fitBounds([lon, lat], [lon, lat], [20, 0], 1000);
Sets the camera to center around the provided coordinate using a realistic 'travel'
animation, with optional duration.
Name | Type | Required | Description |
---|
camera.flyTo([lon, lat]);
camera.flyTo([lon, lat], 12000);
Sets the camera to center around the provided coordinate, with optional duration.
Name | Type | Required | Description |
---|
camera.moveTo([lon, lat], 200);
camera.moveTo([lon, lat]);
Zooms the camera to the provided level, with optional duration.
Name | Type | Required | Description |
---|
camera.zoomTo(16);
camera.zoomTo(16, 100);