Class TrackingCameraBehavior

java.lang.Object
com.here.NativeBase
com.here.sdk.navigation.TrackingCameraBehavior
All Implemented Interfaces:
CameraBehavior

public final class TrackingCameraBehavior extends NativeBase implements 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.

  • 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.

    • setManeuverModeConfiguration

      public void setManeuverModeConfiguration(@Nullable TrackingCameraBehavior.ManeuverModeConfiguration maneuverModeConfiguration)

      Sets the configuration for camera behavior near maneuvers. Defines how the camera reacts to nearby maneuvers when isManeuverDetectionEnabled() is true. When set to null, the camera does not react to maneuvers. The configuration must contain at least one rule to be valid. Defaults to null.

      Parameters:
      maneuverModeConfiguration -

      The maneuver mode configuration. Invalid configurations are rejected.

    • getManeuverModeConfiguration

      @Nullable public TrackingCameraBehavior.ManeuverModeConfiguration getManeuverModeConfiguration()

      Gets the current maneuver mode configuration, or null if not set.

      Returns:

      The current maneuver mode configuration.

    • defaultFunctionalRoadClassZoomPolicyOptions

      @NonNull public static TrackingCameraBehavior.FunctionalRoadClassZoomPolicyOptions defaultFunctionalRoadClassZoomPolicyOptions()
      Returns:

      The default TrackingCameraBehavior.FunctionalRoadClassZoomPolicyOptions.

    • defaultSpeedBasedZoomPolicyOptions

      @NonNull public static TrackingCameraBehavior.SpeedBasedZoomPolicyOptions defaultSpeedBasedZoomPolicyOptions()
      Returns:

      The default TrackingCameraBehavior.SpeedBasedZoomPolicyOptions.

    • defaultManeuverModeConfiguration

      @NonNull public static TrackingCameraBehavior.ManeuverModeConfiguration defaultManeuverModeConfiguration()
      Returns:

      The default TrackingCameraBehavior.ManeuverModeConfiguration.

    • getRecenterAnimationDuration

      @NonNull public Duration 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

      public void setRecenterAnimationDuration(@NonNull Duration value)

      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.

    • getViewRectangle

      @Nullable public Rectangle2D getViewRectangle()

      Gets the current view rectangle, if it's set.

      Defines a sub-space of the screen that the behavior should consider for camera updates. Defaults to null. If not set, it uses the viewport bounds of the underlying map view.

      Returns:

      The view rectangle for camera updates.

    • setViewRectangle

      public void setViewRectangle(@Nullable Rectangle2D value)

      Sets a view rectangle.

      Defines a sub-space of the screen that the behavior should consider for camera updates. Defaults to null. If not set, it uses the viewport bounds of the underlying map view.

      Parameters:
      value -

      The view rectangle for camera updates.

    • getPrincipalPointAnimationDuration

      @NonNull public Duration 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

      public void setPrincipalPointAnimationDuration(@NonNull Duration value)

      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

      @Nullable public Double 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 the Location, so that it points to the direction of travel. If this property is null and the device does not provide bearing, the last known value is used or zero otherwise.

      Returns:

      The camera bearing in degrees.

    • setBearingInDegrees

      public void setBearingInDegrees(@Nullable Double value)

      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 the Location, so that it points to the direction of travel. If this property is null and 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

      @NonNull public TrackingCameraBehavior.ZoomPolicy getZoomPolicy()

      Gets the current zoom computation strategy.

      Defines the strategy used to compute the zoom level based on scene heuristics. Defaults to a fixed zoom policy at zoom level 16.5.

      Returns:

      The strategy of computing the zoom level.

    • setZoomPolicy

      public void setZoomPolicy(@NonNull TrackingCameraBehavior.ZoomPolicy value)

      Sets the current zoom computation strategy.

      Defines the strategy used to compute the zoom level based on scene heuristics. Defaults to a fixed zoom policy at zoom level 16.5.

      Parameters:
      value -

      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 the TrackingCameraBehavior.ManeuverModeConfiguration set via setManeuverModeConfiguration(com.here.sdk.navigation.TrackingCameraBehavior.ManeuverModeConfiguration). A valid TrackingCameraBehavior.ManeuverModeConfiguration must be set for the camera to react. Defaults to false.

      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 the TrackingCameraBehavior.ManeuverModeConfiguration set via setManeuverModeConfiguration(com.here.sdk.navigation.TrackingCameraBehavior.ManeuverModeConfiguration). A valid TrackingCameraBehavior.ManeuverModeConfiguration must be set for the camera to react. Defaults to false.

      Parameters:
      value -

      Whether maneuver detection is enabled.

    • getNormalizedPrincipalPoint

      @NonNull public Anchor2D 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:
      getNormalizedPrincipalPoint in interface CameraBehavior
      Returns:

      The normalized principal point.

    • setNormalizedPrincipalPoint

      public void setNormalizedPrincipalPoint(@NonNull Anchor2D value)

      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:
      setNormalizedPrincipalPoint in interface CameraBehavior
      Parameters:
      value -

      The normalized principal point.