import { Camera } from '@rnmapbox/maps';
CameraControls 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} />
);literalAllows static check of the data type. For internal use only.
PositionThe location on which the map should center.
intersectionThe corners of a box around which the map should bound. Contains padding props for backwards
compatibility; the root padding prop should be used instead.
numberThe heading (orientation) of the map.
numberThe pitch of the map.
numberThe 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.
numberThe 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.
booleanWhether the map orientation follows the user location.
UserTrackingModeThe mode used to track the user location on the map.
numberThe zoom level used when following the user location.
numberThe pitch used when following the user location.
numberThe heading used when following the user location.
PartialThe padding used to position the user location when following.
numberThe lowest allowed zoom level.
numberThe 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.
booleanWhether 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 | numberAny arbitrary primitive value that, when changed, causes the camera to retry moving to its target configuration. (Not yet implemented.)
funcExecutes 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);