-
Viewportprovides 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 -
ViewportStatuscontains 3 cases that express what theViewportis 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 -
ViewportStatusObservermust be implemented by objects that wish to register themselves usingaddStatusObserver(_:)so that they can observestatuschanges.See moreSee also
addStatusObserver(_:)for an important note about how these notifications are delivered asynchronously.Declaration
Swift
public protocol ViewportStatusObserver : AnyObject -
ViewportStateis a protocol thatViewportdepends on as it orchestrates transitions to and from different states.A
ViewportStateis a reference type and must not be shared among multipleViewportinstances simultaneously.The
observeDataSource(with:)method allowsViewportTransitions 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 byViewportitself after a successful transition into a state and when exiting a state, respectively.MapboxMaps provides implementations of
ViewportStatethat 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
ViewportStateimplementation 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 moreSee also
transitionsToIdleUponUserInteractionDeclaration
Swift
public struct FollowPuckViewportStateOptions : Hashable -
Expresses the different ways that
FollowPuckViewportStatecan obtain values to use when settingbearing.See moreSee also
puckBearingSourceDeclaration
Swift
public enum FollowPuckViewportStateBearing : Hashable -
A
ViewportStateimplementation 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 -
ViewportTransitionis a protocol thatViewportdepends on as it orchestrates transitions to and from differentViewportStates.MapboxMaps provides implementations of
See moreViewportTransitionthat 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
ViewportTransitionimplementation.Use
See moremakeDefaultViewportTransition(options:)to create instances of this class.Declaration
Swift
public final class DefaultViewportTransitionextension DefaultViewportTransition: ViewportTransition -
Configuration options for
See moreDefaultViewportTransition.Declaration
Swift
public struct DefaultViewportTransitionOptions : Hashable -
A
ViewportTransitionimplementation that transitions immediately without any animation.Use
makeImmediateViewportTransition()to create instances of this class.Declaration
Swift
public final class ImmediateViewportTransition : ViewportTransition
Viewport Reference