Class MapView.CameraController

  • Enclosing class:
    MapView

    public final class MapView.CameraController
    extends java.lang.Object
    CameraController provides the ability to manage map rotation, tilt and zoom via changing the camera position (heading, tilt and zoom) instantly or animated. It also allows to listen to the camera position changes which can be invoked:
    • by the user interaction with the map (gestures)
    • by animating or moving the camera using methods of CameraController
    • by the SDK itself (for example, when option to follow the GPS postion is set in MapView).
    • Field Detail

      • DEFAULT_ANIMATION_DURATION

        public static final float DEFAULT_ANIMATION_DURATION
        See Also:
        Constant Field Values
    • Method Detail

      • getCameraPosition

        public CameraPosition getCameraPosition()
        Returns the current camera position. See CameraPosition for more information.
        Returns:
        The camera position.
      • getCameraPositionForMapRectangle

        public CameraPosition getCameraPositionForMapRectangle​(MapRectangle mapRectangle,
                                                               float heading,
                                                               float tilt)
      • getCameraPositionForMapRectangle

        public CameraPosition getCameraPositionForMapRectangle​(MapRectangle mapRectangle,
                                                               float heading,
                                                               float tilt,
                                                               @Nullable
                                                               android.graphics.Rect padding,
                                                               float maxZoomLevel)
      • getMapRectangleForCameraPosition

        public MapRectangle getMapRectangleForCameraPosition​(CameraPosition cameraPosition)
        Returns visible map region for the specified camera position.

        For this method to work, the view must have valid width and height.

        Parameters:
        cameraPosition - The position of the camera.
        Returns:
        The visible region.
      • moveCamera

        public void moveCamera​(CameraPosition cameraPosition)
        Changes the camera position instantly, without animation.
        Parameters:
        cameraPosition - The new position of the camera.
      • animateCamera

        public void animateCamera​(CameraPosition cameraPosition)
        Changes the camera position with animation. The default animation duration is 0.5f seconds.
        Parameters:
        cameraPosition - The new position of the camera.
      • animateCamera

        public void animateCamera​(CameraPosition cameraPosition,
                                  @Nullable
                                  MapView.CameraAnimationListener cameraAnimationListener)
        Changes the camera position with animation and notifies the specified listener when the animation is finished. The default animation duration is 0.5f seconds.
        Parameters:
        cameraPosition - The new position of the camera.
        cameraAnimationListener - The listener to notify when the animation ends. This parameter may be null. See MapView.CameraAnimationListener for more information.
      • animateCamera

        public void animateCamera​(CameraPosition cameraPosition,
                                  float duration,
                                  MapView.CameraAnimationListener cameraAnimationListener)
        Changes the camera position with animation and notifies the listener when the animation is finished.
        Parameters:
        cameraPosition - The new position of the camera.
        duration - The total duration of the animation, measured in seconds. If you specify 0, the changes are made without animation.
        cameraAnimationListener - The listener to notify the animation ends. This parameter may be null. See MapView.CameraAnimationListener for more information.
      • removeCameraMovementListener

        public void removeCameraMovementListener​(MapView.CameraMovementListener listener)
        Removes the specified listener from the list.
        Parameters:
        listener - The listener.