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.
number[] | [number, number]
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.
TODO 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.
TODO The corners of a box defining the limits of where the camera can pan or zoom.
TODO 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.
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);