Enable or disable the ability for the user to interact with the camera (e.g. pan, zoom, tilt, etc). This does not affect programmatic camera controls, such as set and focusOn.
// The user can no longer interact to move the camera
mapView.Camera.interactions.disable();
// The user can now interact to move the camera again
mapView.Camera.interactions.enable();
Disable all user interactions.
Enable all user interactions.
Enable or disable specific user interactions.
mapView.Camera.interactions.set({ zoom: false });
An object defining the interactions to switch on or off.
Unsubscribe a function that was previously subscribed with on.
mapView.Camera.on(E_CAMERA_EVENT.CHANGED, cameraChangedHandler);
...
// Something changed and I no longer want this event to fire
mapView.Camera.off(E_CAMERA_EVENT.CHANGED, cameraChangedHandler);
An E_CAMERA_EVENT that is fired when the camera changes.
A function that was previously passed to on. The function must have the same reference as the function that was subscribed.
Subscribe a function to be called when an E_CAMERA_EVENT is fired.
const cameraChangedHandler = ({ tilt, position, zoom, rotation }) => {
// Do something with the new values
};
mapView.Camera.on(E_CAMERA_EVENT.CHANGED, cameraChangedHandler);
An E_CAMERA_EVENT that is fired when the camera changes.
A callback that gets called when the corresponding event is fired. The callback will get passed an argument with a type that's one of CAMERA_EVENT_PAYLOAD.
The current camera animation, if any. Resolves when the animation finishes.
Get the current maximum tilt angle (in radians) the camera is allowed to use.
Sets the maximum tilt angle (in radians) the camera is allowed to use.
Tilt angle must be between 0 and π/2 radians. It will be clamped within this range if it exceeds it on either end.
As tilt angle approaches π/2 radians, this will impact overall touch controls and should be used sparingly.
Get the maximum distance (in meters) the camera is allowed to get from the ground.
Set the maximum distance (in meters) the camera is allowed to get from the ground.
Get the minimum distance (in meters) the camera is allowed to get to the ground.
Set the minimum distance (in meters) the camera is allowed to get to the ground.
Get the current camera position, which is at the center of the map.
the position as a coordinate
Current Camera rotation (in radians) from north
Current camera tilt angle (in radians), relative to a top-down view.
ex: 0 means the camera is facing top-down, π/2 means the camera is facing directly from the side.
Current Camera zoom (in meters)
Smoothly transition the camera's transform to be in a new configuration. See also set.
const coord = mapView.venue.maps[0].createCoordinate(33.66107, 31.83911);
// Animate the camera to be top-down at a specified coordinate
mapView.Camera.animate({
tilt: 0,
position: coord,
});
The new transform of the camera.
Optional
options: TAnimationOptionsa Promise that resolves when the animation finishes, or rejects when it is cancelled.
Animate the camera to focus on a collection of targets. To control where the targets should
be placed on screen, either specify safeAreaInsets
on the TFocusOnCameraOptions
or call setSafeAreaInsets.
const location = mapView.venue.locations.find((l) => l.name === "My Location")!;
mapView.Camera.focusOn({
polygons: location.polygons,
nodes: location.nodes,
});
A collection of things that the camera will place into view at the end of the animation.
Optional
options: TFocusOnCameraOptions & TAnimationOptionsa Promise that resolves when the animation finishes, or rejects when it is cancelled.
Retrieve the values previously set by setSafeAreaInsets.
An object defining a number of pixels from the top, left, bottom, and right of the screen.
Instantaneously set the camera's transform to be in a new configuration. See also animate.
const coord = mapView.venue.maps[0].createCoordinate(33.66107, 31.83911);
// Place the camera top-down at a specified coordinate
mapView.Camera.set({
tilt: 0,
position: coord,
});
The new transform of the camera.
Define an area of the screen that is safe for the camera. Anything outside the safe area is assumed to be covered in some way (e.g. by UI) meaning the camera will not place any map elements there when calling focusOn.
// The top 100px of the canvas are covered by a UI element
mapView.Camera.setSafeAreaInsets({ top: 100, left: 0, bottom: 0, right: 0});
mapView.Camera.focusOn({ nodes });
An object defining a number of pixels from the top, left, bottom, and right of the screen. Only the area within the padding defined by these pixels is considered safe.
Moves the Camera view in a relative direction by a given distance in meters.
// Move the camera 50 meters up relative to the camera frame
mapView.Camera.translate(E_CAMERA_DIRECTION.UP, 50);
Optional
options: TAnimationOptionsa Promise that resolves when the translation animation finishes, or rejects when it is cancelled.
API to control and respond to the state of the camera within the scene.