TrackingCameraBehavior (API Reference)
Class TrackingCameraBehavior
- All Implemented Interfaces:
CameraBehavior
Use this class to follow a moving target. The camera smoothly tracks the target’s position while adjusting heading, tilt, and zoom as needed. When tracking starts or resumes, the camera first animates a re-centering transition to align with the target.
Note: This is a beta feature; there maybe bugs and unexpected behavior. Related API's are subject to change without a deprecation process.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfiguration for mapping functional road classes to zoom levels.static final classConfiguration that defines howTrackingCameraBehaviorreacts to nearby maneuvers.static final classDefines a single rule that determines howTrackingCameraBehaviorreacts to nearby maneuvers when the current position matches this rule.static final classDefines a set of configurations specific to aTrackingCameraBehavior.ManeuverRule.static final classDefines the bounds within which the zoom level is constrained when approaching a maneuver.static final classConfiguration for computing zoom levels from speed thresholds defined per road classification.static final classDefines a zoom level triggered when the vehicle reaches a specific speed.static final classDefines zoom behavior in different policy settings. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEnables fixed-duration animation mode for the next property change.Gets the bearing in degrees.Gets the current crop rectangle, if it's set.Gets the current maneuver mode configuration, ornullif not set.doubleGets the maximum rotation speed.Gets the currently set normalized principal point to be used during navigation.Gets the current principal point animation duration in milliseconds.Gets the recenter animation duration in milliseconds.doubleGets the camera tilt in degrees.Gets the current zoom computation strategy.doubleGets the zoom level transition speed.booleanGets whether maneuver detection is enabled.voidsetBearingInDegrees(Double value) Sets the bearing in degrees.voidsetCropRectangle(Rectangle2D value) Sets a crop rectangle.voidsetManeuverDetectionEnabled(boolean value) Sets whether maneuver detection is enabled.voidSets the maneuver mode configuration.voidsetMaxRotationSpeedInDegreesPerSecond(double value) Sets the maximum rotation speed.voidSets a normalized principal point to be used during navigation.voidSets the current principal point animation in milliseconds.voidSets the recenter animation duration in milliseconds.voidsetTiltInDegrees(double value) Sets the camera tilt in degrees.voidSets the current zoom computation strategy.voidsetZoomSpeedInLevelsPerSecond(double value) Sets the zoom level transition speed.
-
Constructor Details
-
TrackingCameraBehavior
public TrackingCameraBehavior()Creates a new instance of this class.
-
-
Method Details
-
flagFixedDurationForNextAnimation
public void flagFixedDurationForNextAnimation()Enables fixed-duration animation mode for the next property change. When called, the next setter call (e.g., tilt_in_degrees or bearing_in_degrees) will animate using a fast fixed-duration animation instead of the default speed-based animation. The flag is automatically reset after the next setter is called.
-
getRecenterAnimationDuration
Gets the recenter animation duration in milliseconds.
Time to recenter the camera reaching current car position. Defaults to 500 milliseconds, or half a second.
- Returns:
The duration of recenter animation in milliseconds.
-
setRecenterAnimationDuration
Sets the recenter animation duration in milliseconds.
Time to recenter the camera reaching current car position. Defaults to 500 milliseconds, or half a second.
- Parameters:
value-The duration of recenter animation in milliseconds.
-
getCropRectangle
Gets the current crop rectangle, if it's set.
Defines a sub-space of the screen that the behavior should consider for camera updates. If not set, it uses the viewport bounds of the underlying map view.
- Returns:
The crop rectangle for camera updates.
-
setCropRectangle
Sets a crop rectangle.
Defines a sub-space of the screen that the behavior should consider for camera updates. If not set, it uses the viewport bounds of the underlying map view.
- Parameters:
value-The crop rectangle for camera updates.
-
getPrincipalPointAnimationDuration
Gets the current principal point animation duration in milliseconds.
If the principal point is changed, the change will be animated over this duration. Defaults to 500 milliseconds, or half a second.
- Returns:
The duration of principal point animation in milliseconds.
-
setPrincipalPointAnimationDuration
Sets the current principal point animation in milliseconds.
If the principal point is changed, the change will be animated over this duration. Defaults to 500 milliseconds, or half a second.
- Parameters:
value-The duration of principal point animation in milliseconds.
-
getTiltInDegrees
public double getTiltInDegrees()Gets the camera tilt in degrees.
Camera tilt angle relative to the ground plane, in degrees. Defaults to 50.
- Returns:
The value of camera tilt in degrees.
-
setTiltInDegrees
public void setTiltInDegrees(double value) Sets the camera tilt in degrees.
Camera tilt angle relative to the ground plane, in degrees. Defaults to 50.
- Parameters:
value-The value of camera tilt in degrees.
-
getBearingInDegrees
Gets the bearing in degrees.
Optional fixed bearing, from true North (0 degrees) in clockwise direction. The valid range is [0, 360]. If set, it will prevent the map from rotating to the direction of travel. For example, a value of zero results in "north up" mode. Defaults to
null, which means the camera derives the bearing from theLocation, so that it points to the direction of travel. If this property isnulland the device does not provide bearing, the last known value is used or zero otherwise.- Returns:
The camera bearing in degrees.
-
setBearingInDegrees
Sets the bearing in degrees.
Optional fixed bearing, from true North (0 degrees) in clockwise direction. The valid range is [0, 360]. If set, it will prevent the map from rotating to the direction of travel. For example, a value of zero results in "north up" mode. Defaults to
null, which means the camera derives the bearing from theLocation, so that it points to the direction of travel. If this property isnulland the device does not provide bearing, the last known value is used or zero otherwise.- Parameters:
value-The camera bearing in degrees.
-
getMaxRotationSpeedInDegreesPerSecond
public double getMaxRotationSpeedInDegreesPerSecond()Gets the maximum rotation speed.
Maximum bearing rotation speed in degrees per second, limiting how fast the camera turns. Defaults to 20 degrees per second.
- Returns:
The maximum rotation speed.
-
setMaxRotationSpeedInDegreesPerSecond
public void setMaxRotationSpeedInDegreesPerSecond(double value) Sets the maximum rotation speed.
Maximum bearing rotation speed in degrees per second, limiting how fast the camera turns. Defaults to 20 degrees per second.
- Parameters:
value-The maximum rotation speed.
-
getZoomSpeedInLevelsPerSecond
public double getZoomSpeedInLevelsPerSecond()Gets the zoom level transition speed.
Speed factor controlling how quickly the camera transitions between zoom levels Defaults to 0.5 zoom levels per second.
- Returns:
The zoom level transition speed.
-
setZoomSpeedInLevelsPerSecond
public void setZoomSpeedInLevelsPerSecond(double value) Sets the zoom level transition speed.
Speed factor controlling how quickly the camera transitions between zoom levels Defaults to 0.5 zoom levels per second.
- Parameters:
value-The zoom level transition speed.
-
getZoomPolicy
Gets the current zoom computation strategy.
Defines the strategy used to compute the zoom level based on scene heuristics.
- Returns:
The strategy of computing the zoom level.
-
isManeuverDetectionEnabled
public boolean isManeuverDetectionEnabled()Gets whether maneuver detection is enabled.
When
true, the camera detects adjacent maneuvers and reacts according to thegetManeuverModeConfiguration(). A validTrackingCameraBehavior.ManeuverModeConfigurationmust be set for the camera to react. Defaults tofalse.- Returns:
Whether maneuver detection is enabled.
-
setManeuverDetectionEnabled
public void setManeuverDetectionEnabled(boolean value) Sets whether maneuver detection is enabled.
When
true, the camera detects adjacent maneuvers and reacts according to thegetManeuverModeConfiguration(). A validTrackingCameraBehavior.ManeuverModeConfigurationmust be set for the camera to react. Defaults tofalse.- Parameters:
value-Whether maneuver detection is enabled.
-
getManeuverModeConfiguration
Gets the current maneuver mode configuration, or
nullif not set.Defines how the camera reacts to nearby maneuvers when
isManeuverDetectionEnabled()istrue. When set tonull, the camera does not react to maneuvers. The configuration must contain at least one rule to be valid.- Returns:
The configuration for camera behavior near maneuvers.
-
getNormalizedPrincipalPoint
Gets the currently set normalized principal point to be used during navigation.
Normalized principal point to be used during navigation. Defaults to (0.5, 0.775), which means the camera will use the position slightly at the bottom of the mapview.
- Specified by:
getNormalizedPrincipalPointin interfaceCameraBehavior- Returns:
The normalized principal point.
-
setNormalizedPrincipalPoint
Sets a normalized principal point to be used during navigation.
Normalized principal point to be used during navigation. Defaults to (0.5, 0.775), which means the camera will use the position slightly at the bottom of the mapview.
- Specified by:
setNormalizedPrincipalPointin interfaceCameraBehavior- Parameters:
value-The normalized principal point.
-