animate

suspend fun animate(update: CameraUpdate, durationMs: Int = MAX_VALUE)

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. If Int.MAX_VALUE is provided, the default animation duration will be used. Otherwise, the value provided must be strictly positive, otherwise an IllegalArgumentException will be thrown.