-
public final class CameraPositionStateA 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classCameraPositionState.Companion
-
Field Summary
Fields Modifier and Type Field Description private BooleanisMovingprivate final Projectionprojectionprivate CameraPositionposition
-
Constructor Summary
Constructors Constructor Description CameraPositionState(CameraPosition position)
-
Method Summary
Modifier and Type Method Description final BooleangetIsMoving()Whether the camera is currently moving or not. final UnitsetIsMoving(Boolean isMoving)final ProjectiongetProjection()final CameraPositiongetPosition()final UnitsetPosition(CameraPosition position)final Unitanimate(CameraUpdate update, Integer durationMs)Animate the camera position as specified by update, returning once the animation has completed. final Unitmove(CameraUpdate update)Move the camera instantaneously as specified by update. -
-
Method Detail
-
getIsMoving
final Boolean getIsMoving()
Whether the camera is currently moving or not. This includes any kind of movement: panning, zooming, or rotation.
-
setIsMoving
final Unit setIsMoving(Boolean isMoving)
-
getProjection
final Projection getProjection()
-
getPosition
final CameraPosition getPosition()
-
setPosition
final Unit setPosition(CameraPosition position)
-
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 cameradurationMs- 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.
-
-
-
-