MapViewLifecycleDelegate
public protocol MapViewLifecycleDelegate : AnyObject
Provides a mechanism for observing a lifecycle of a map view and/or implementing components whose lifecycle needs to be linked with that of a map view.
Storing the map view in a strong reference is strongly discouraged, as that will create a reference cycle and prevent map view from being released.
A MapView is using a
CAMetalLayer
to render its content.
-
Called when adding
MapViewLifecycleDelegateto the map view. If the map view does not have render target attached at the time of adding the listener, then this method will be called later, after render target is attached. This means that the map view it receives is always fully initialized.Can be used to implement the logic to create and add visual components to the map view.
Storing the map view in a strong reference is strongly discouraged, as that will create a reference cycle and prevent map view from being released.
Declaration
Swift
func onAttach(to mapView: MapViewBase)Parameters
mapViewThe map view to attach to.
-
Called when removing
MapViewLifecycleDelegatefrom the map view. Can be used to implement the logic to remove visual components from the map view and release resources if necessary.Declaration
Swift
func onDetach(from mapView: MapViewBase)Parameters
mapViewThe map view to detach from.
-
Called when the map view to which this
MapViewLifecycleDelegateis attached to gets paused (usually when the app goes into background). This should be used by components that perform continuous updates to pause those updates untilonResume(...)is called.Declaration
Swift
func onPause() -
Called when the map view to which this
MapViewLifecycleDelegateis attached to gets resumed (usually when the app goes into foreground). This should be used by components that perform continuous updates to resume those updates after a previous call toonPause(...).Declaration
Swift
func onResume() -
Called when the map view to which this is attached to is destroyed. After this is called, no other
MapViewLifecycleDelegatemethod will be invoked. This should be used to make sure all resources are freed.Declaration
Swift
func onDestroy()