ViewportState

interface ViewportState

ViewportState is used to observe the data source associated with the state and query the camera to keep updating according to current viewport data. ViewportState is also used by ViewportPlugin to orchestrate transitions to and from different states.

The observeDataSource allows ViewportTransition to consume a stream of camera updates from a target state while executing a transition.

The startUpdatingCamera and stopUpdatingCamera are invoked to tell the state that it should assume or relinquish control of the map's camera. These are typically used by ViewportPlugin itself after a successful transition into a state and when exiting a state, respectively.

Mapbox provides implementations of ViewportState that can be created and configured via methods on ViewportPlugin. Applications may also define their own implementations to handle advanced use cases not covered by the provided implementations.

ViewportState should generally pre-warm their data sources as soon as they are created to minimise delays when they become current. For this reason, only states that are current(or soon-to-be) needed should be kept alive so that unneeded resources(e.g. location services) can be released.

Note: Users are responsible to create the viewport states and keep a reference to these states for future operations.

See also

Functions

observeDataSource
Link copied to clipboard
abstract fun observeDataSource(viewportStateDataObserver: ViewportStateDataObserver): Cancelable

Registers an observer to receive the cameras being generated by this ViewportState.

startUpdatingCamera
Link copied to clipboard
abstract fun startUpdatingCamera()

Indicates the current ViewportState is now responsible for updating the camera.

stopUpdatingCamera
Link copied to clipboard
abstract fun stopUpdatingCamera()

Indicates the current ViewportState is no longer responsible for updating the camera.

Inheritors

FollowPuckViewportState
Link copied to clipboard
OverviewViewportState
Link copied to clipboard