-
Viewport
provides a structured approach to organizing camera management logic into states and transitions between them.At any given time, the viewport is either:
- idle (not updating the camera)
- in a state (camera is being managed by a
ViewportState
) - transitioning (camera is being managed by a
ViewportTransition
)
Declaration
Swift
public final class Viewport
-
ViewportStatus
contains 3 cases that express what theViewport
is doing at any given time.The
See morestate(_:)
andtransition(_:toState:)
cases have associated values that are reference types, so equality and hash are implemented in terms of the identities of those objects.Declaration
Swift
public enum ViewportStatus : Hashable
-
ViewportStatusObserver
must be implemented by objects that wish to register themselves usingaddStatusObserver(_:)
so that they can observestatus
changes.See also
addStatusObserver(_:)
for an important note about how these notifications are delivered asynchronously.Declaration
Swift
public protocol ViewportStatusObserver : AnyObject
-
ViewportState
is a protocol thatViewport
depends on as it orchestrates transitions to and from different states.A
ViewportState
is a reference type and must not be shared among multipleViewport
instances simultaneously.The
observeDataSource(with:)
method allowsViewportTransition
s to consume a stream of camera updates from a target state while executing a transition.startUpdatingCamera()
andstopUpdatingCamera()
are invoked to tell the state that it should assume or relinquish control of the map’s camera. These are typically used byViewport
itself after a successful transition into a state and when exiting a state, respectively.MapboxMaps provides implementations of
ViewportState
that can be created and configured via methods onViewport
. Applications may also define their own implementations to handle advanced use cases not covered by the provided implementations.States should generally pre-warm their data sources as soon as they are created to minimize delays when they become current. For this reason, only states that are currently (or soon-to-be) needed should be kept alive so that unneeded resources (e.g. location services) can be released.
See moreDeclaration
Swift
public protocol ViewportState : AnyObject
-
A
ViewportState
implementation that tracks the location puck (to show a puck, usepuckType
)Use
See moremakeFollowPuckViewportState(options:)
to create instances of this class.Declaration
-
Configuration options for
FollowPuckViewportState
.Each of the
CameraOptions
-related properties is optional, so that the state can be configured to only modify certain aspects of the camera if desired. This can be used, to achieve effects like allowing zoom gestures to work simultaneously withFollowPuckViewportState
.See also
transitionsToIdleUponUserInteraction
Declaration
Swift
public struct FollowPuckViewportStateOptions : Hashable
-
Expresses the different ways that
FollowPuckViewportState
can obtain values to use when settingbearing
.See also
puckBearing
Declaration
Swift
public enum FollowPuckViewportStateBearing : Hashable
-
A
ViewportState
implementation that shows an overview of the geometry specified by itsgeometry
.Use
See moremakeOverviewViewportState(options:)
to create instances of this class.Declaration
-
Configuration options for
See moreOverviewViewportState
.Declaration
Swift
public struct OverviewViewportStateOptions : Equatable
-
ViewportTransition
is a protocol thatViewport
depends on as it orchestrates transitions to and from differentViewportState
s.MapboxMaps provides implementations of
See moreViewportTransition
that can be created and configured via methods onViewport
. Applications may also define their own implementations to handle advanced use cases not covered by the provided implementations.Declaration
Swift
public protocol ViewportTransition : AnyObject
-
A default
ViewportTransition
implementation.Use
See moremakeDefaultViewportTransition(options:)
to create instances of this class.Declaration
Swift
public final class DefaultViewportTransition
extension DefaultViewportTransition: ViewportTransition
-
Configuration options for
See moreDefaultViewportTransition
.Declaration
Swift
public struct DefaultViewportTransitionOptions : Hashable
-
A
ViewportTransition
implementation that transitions immediately without any animation.Use
makeImmediateViewportTransition()
to create instances of this class.Declaration
Swift
public final class ImmediateViewportTransition : ViewportTransition