CameraAnimationsPluginImpl

class CameraAnimationsPluginImpl : CameraAnimationsPlugin

CameraAnimationsPluginImpl is designed to rule all the animations happening to the map driven by changing CameraOptions. It is responsible for:

  • Storing all the ValueAnimator's that could be run. Only specific camera animators could be used in this plugin.

  • Controlling animation execution - only one ValueAnimator of certain type could be run at a time. If some another animation with same CameraAnimator.type is about to start previous one will be cancelled.

  • Giving possibility to listen to CameraOptions values changes during animations via listeners.

  • If several animations of different CameraAnimator.type are running simultaneously map camera will be updated only on oldest animation update (the oldest is the one that was started first). That actually means that animation start order matters. High-level animations flyTo and easeTo will always trigger camera center animator first.

CameraAnimationsPluginImpl is NOT thread-safe meaning all animations must be started from one thread. However, it doesn't have to be the UI thread.

Constructors

CameraAnimationsPluginImpl
Link copied to clipboard
fun CameraAnimationsPluginImpl()

Types

Companion
Link copied to clipboard
object Companion

Static variables and methods.

Functions

addCameraAnchorChangeListener
Link copied to clipboard
open override fun addCameraAnchorChangeListener(listener: CameraAnimatorNullableChangeListener<ScreenCoordinate?>)

Add CameraAnimatorNullableChangeListener to receive map anchor updates.

addCameraAnimationsLifecycleListener
Link copied to clipboard
open override fun addCameraAnimationsLifecycleListener(listener: CameraAnimationsLifecycleListener)

Add given CameraAnimationsLifecycleListener for capturing all events about animators lifecycle.

addCameraBearingChangeListener
Link copied to clipboard
open override fun addCameraBearingChangeListener(listener: CameraAnimatorChangeListener<Double>)

Add CameraAnimatorChangeListener to receive map bearing updates.

addCameraCenterChangeListener
Link copied to clipboard
open override fun addCameraCenterChangeListener(listener: CameraAnimatorChangeListener<Point>)

Add CameraAnimatorChangeListener to receive map center updates.

addCameraPaddingChangeListener
Link copied to clipboard
open override fun addCameraPaddingChangeListener(listener: CameraAnimatorChangeListener<EdgeInsets>)

Add CameraAnimatorChangeListener to receive map padding updates.

addCameraPitchChangeListener
Link copied to clipboard
open override fun addCameraPitchChangeListener(listener: CameraAnimatorChangeListener<Double>)

Add CameraAnimatorChangeListener to receive map pitch updates.

addCameraZoomChangeListener
Link copied to clipboard
open override fun addCameraZoomChangeListener(listener: CameraAnimatorChangeListener<Double>)

Add CameraAnimatorChangeListener to receive map zoom updates.

calculateScaleBy
Link copied to clipboard
open override fun calculateScaleBy(amount: Double, currentZoom: Double): Double

Calculate target zoom by applying scale

cancelAllAnimators
Link copied to clipboard
open override fun cancelAllAnimators(exceptOwnerList: List<String>)

Cancel all animators except ones owned by exceptOwnerList list.

cleanup
Link copied to clipboard
open override fun cleanup()

Called when the map is destroyed. Should be used to cleanup plugin resources for that map. Cancel all running animations and cleanup all resources (registered animations, listeners).

createAnchorAnimator
Link copied to clipboard
open override fun createAnchorAnimator(options: CameraAnimatorOptions<ScreenCoordinate>, block: ValueAnimator.() -> Unit?): ValueAnimator

Create CameraAnchorAnimator

createBearingAnimator
Link copied to clipboard
open override fun createBearingAnimator(options: CameraAnimatorOptions<Double>, useShortestPath: Boolean, block: ValueAnimator.() -> Unit?): ValueAnimator

Create CameraBearingAnimator. Current map camera option will be applied on animation start if not specified explicitly with options.startValue.

createCenterAnimator
Link copied to clipboard
open override fun createCenterAnimator(options: CameraAnimatorOptions<Point>, block: ValueAnimator.() -> Unit?): ValueAnimator

Create CameraCenterAnimator. Current map camera option will be applied on animation start if not specified explicitly with options.startValue.

createPaddingAnimator
Link copied to clipboard
open override fun createPaddingAnimator(options: CameraAnimatorOptions<EdgeInsets>, block: ValueAnimator.() -> Unit?): ValueAnimator

Create CameraPaddingAnimator. Current map camera option will be applied on animation start if not specified explicitly with options.startValue.

createPitchAnimator
Link copied to clipboard
open override fun createPitchAnimator(options: CameraAnimatorOptions<Double>, block: ValueAnimator.() -> Unit?): ValueAnimator

Create CameraPitchAnimator. Current map camera option will be applied on animation start if not specified explicitly with options.startValue.

createZoomAnimator
Link copied to clipboard
open override fun createZoomAnimator(options: CameraAnimatorOptions<Double>, block: ValueAnimator.() -> Unit?): ValueAnimator

Create CameraZoomAnimator

easeTo
Link copied to clipboard
open override fun easeTo(cameraOptions: CameraOptions, animationOptions: MapAnimationOptions?): Cancelable

Ease the map camera to a given camera options and animation options.

flyTo
Link copied to clipboard
open override fun flyTo(cameraOptions: CameraOptions, animationOptions: MapAnimationOptions?): Cancelable

Fly the map camera to a given camera options.

initialize
Link copied to clipboard
open fun initialize()
moveBy
Link copied to clipboard
open override fun moveBy(screenCoordinate: ScreenCoordinate, animationOptions: MapAnimationOptions?): Cancelable

Move the map by a given screen coordinate with optional animation.

onDelegateProvider
Link copied to clipboard
open override fun onDelegateProvider(delegateProvider: MapDelegateProvider)

Provides all map delegate instances.

pitchBy
Link copied to clipboard
open override fun pitchBy(pitch: Double, animationOptions: MapAnimationOptions?): Cancelable

Pitch the map by with optional animation.

playAnimatorsSequentially
Link copied to clipboard
open override fun playAnimatorsSequentially(vararg animators: ValueAnimator)

Play given ValueAnimator's sequentially

playAnimatorsTogether
Link copied to clipboard
open override fun playAnimatorsTogether(vararg animators: ValueAnimator)

Play given ValueAnimator's together

registerAnimators
Link copied to clipboard
open override fun registerAnimators(vararg cameraAnimators: ValueAnimator)

Register given ValueAnimator's. Such ValueAnimator's must be created with static methods like CameraAnimationsPlugin.createCenterAnimator or similar. Only registered animations affect MapboxMap and would not even start otherwise.

removeCameraAnchorChangeListener
Link copied to clipboard
open override fun removeCameraAnchorChangeListener(listener: CameraAnimatorNullableChangeListener<ScreenCoordinate?>)

Remove CameraAnimatorNullableChangeListener. No updates will arrive after that.

removeCameraAnimationsLifecycleListener
Link copied to clipboard
open override fun removeCameraAnimationsLifecycleListener(listener: CameraAnimationsLifecycleListener)

Remove given CameraAnimationsLifecycleListener for capturing all events about animators lifecycle.

removeCameraBearingChangeListener
Link copied to clipboard
open override fun removeCameraBearingChangeListener(listener: CameraAnimatorChangeListener<Double>)

Remove CameraAnimatorChangeListener. No updates will arrive after that.

removeCameraCenterChangeListener
Link copied to clipboard
open override fun removeCameraCenterChangeListener(listener: CameraAnimatorChangeListener<Point>)

Remove CameraAnimatorChangeListener. No updates will arrive after that.

removeCameraPaddingChangeListener
Link copied to clipboard
open override fun removeCameraPaddingChangeListener(listener: CameraAnimatorChangeListener<EdgeInsets>)

Remove CameraAnimatorChangeListener. No updates will arrive after that.

removeCameraPitchChangeListener
Link copied to clipboard
open override fun removeCameraPitchChangeListener(listener: CameraAnimatorChangeListener<Double>)

Remove CameraAnimatorChangeListener. No updates will arrive after that.

removeCameraZoomChangeListener
Link copied to clipboard
open override fun removeCameraZoomChangeListener(listener: CameraAnimatorChangeListener<Double>)

Remove CameraAnimatorChangeListener. No updates will arrive after that.

rotateBy
Link copied to clipboard
open override fun rotateBy(first: ScreenCoordinate, second: ScreenCoordinate, animationOptions: MapAnimationOptions?): Cancelable

Rotate the map by with optional animation.

scaleBy
Link copied to clipboard
open override fun scaleBy(amount: Double, screenCoordinate: ScreenCoordinate?, animationOptions: MapAnimationOptions?): Cancelable

Scale the map by with optional animation.

unregisterAllAnimators
Link copied to clipboard
fun unregisterAllAnimators()

Unregister all previously registered ValueAnimator's.

unregisterAnimators
Link copied to clipboard
open override fun unregisterAnimators(vararg cameraAnimators: ValueAnimator, cancelAnimators: Boolean)

Unregister given ValueAnimator's.

Properties

anchor
Link copied to clipboard
open override var anchor: ScreenCoordinate?

Map camera anchor value. Default value is NULL meaning center of given map view. Left-top corner is represented as ScreenCoordinate (0.0, 0.0).

cameraAnimationsFactory
Link copied to clipboard
lateinit var cameraAnimationsFactory: CameraAnimatorsFactory

Factory to provide animators for the default animations like easeTo, scaleBy, moveBy, rotateBy, pitchBy

debugMode
Link copied to clipboard
open override var debugMode: Boolean = false

If debug mode is enabled extra logs will be written about animation lifecycle and some other events that may be useful for debugging.