Package 

Class CameraPositionState


  • 
    public final class CameraPositionState
    
                        

    A state object that can be hoisted to control and observe the map's camera state. A CameraPositionState may only be used by a single GoogleMap composable at a time as it reflects instance state for a single view of a map.

    • Constructor Summary

      Constructors 
      Constructor Description
      CameraPositionState(CameraPosition position)
    • Method Summary

      Modifier and Type Method Description
      final Boolean getIsMoving() Whether the camera is currently moving or not.
      final Unit setIsMoving(Boolean isMoving)
      final Projection getProjection()
      final CameraPosition getPosition()
      final Unit setPosition(CameraPosition position)
      final Unit animate(CameraUpdate update, Integer durationMs) Animate the camera position as specified by update, returning once the animation has completed.
      final Unit move(CameraUpdate update) Move the camera instantaneously as specified by update.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CameraPositionState

        CameraPositionState(CameraPosition position)
        Parameters:
        position - the initial camera position
    • Method Detail

      • getIsMoving

         final Boolean getIsMoving()

        Whether the camera is currently moving or not. This includes any kind of movement: panning, zooming, or rotation.

      • animate

        @UiThread() final Unit animate(CameraUpdate update, Integer durationMs)

        Animate the camera position as specified by update, returning once the animation has completed. position will reflect the position of the camera as the animation proceeds.

        animate will throw CancellationException if the animation does not fully complete. This can happen if:

        • The user manipulates the map directly

        • position is set explicitly, e.g. state.position = CameraPosition(...)

        • animate is called again before an earlier call to animate returns

        • move is called

        • The calling job is cancelled externally

        If this CameraPositionState is not currently bound to a GoogleMap this call will suspend until a map is bound and animation will begin.

        This method should only be called from a dispatcher bound to the map's UI thread.

        Parameters:
        update - the change that should be applied to the camera
        durationMs - The duration of the animation in milliseconds.
      • move

        @UiThread() final Unit move(CameraUpdate update)

        Move the camera instantaneously as specified by update. Any calls to animate in progress will be cancelled. position will be updated when the bound map's position has been updated, or if the map is currently unbound, update will be applied when a map is next bound. Other calls to move, animate, or setting position will override an earlier pending call to move.

        This method must be called from the map's UI thread.