Other Classes
The following classes are available globally.
-
Creates a view annotation.
Use view annotations if you need to display interactive UIView bound to a geographical coordinate or map feature.
If you need to display large amounts of data or clustering, please consider using
PointAnnotation
or Runtime Styling API, for example,SymbolLayer
withGeoJSONSource
.To display a view annotation configure a UIView, create
ViewAnnotation
, and add it to the view annotation manager:let view = CustomView() view.icon = UIImage(named: "traffic-icon") let annotation = ViewAnnotation( coordinate: CLLocationCoordinate(latitude: 10, longitude: 10), view: view) mapView.viewAnnotations.add(annotation)
The annotation can be displayed on a layer feature referenced by it’s
layerId
andfeatureId
:annotation.annotatedFeature = .layerFeature(layerId: "route-line", featureId: "sf-la")
The view annotation automatically inserts and removes it’s view into the view hierarchy and updates its
isHidden
property.Important
Don’t setUIView.isHidden
property to hide the annotation. Instead, usevisible
property.When view content or layout is updated, use
setNeedsUpdateSize()
to update the the annotation size. It’s safe to use it multiple times, only one update will be performed.view.hintText = "Less Traffic" annotation.setNeedsUpdateSize() // Updates the annotation size.
Note
TheViewAnnotation
usesUIView.systemLayoutSizeFitting(_:)
to measure the view size. Make sure that your view returns the correct size (e.g. implemented using AutoLayout, or returns correct size fromUIView.sizeThatFits(_:)
when layout is manual).To remove annotation when it’s no longer needed, use
See moreremove()
method.Declaration
Swift
public final class ViewAnnotation
-
A Cancellable object that automatically cancels on deinit.
Any resources referred by
AnyCancelable
will be released after cancellation.This class has similar behavior to
See moreCombine.AnyCancellable
, but doesn’t require iOS 13.Declaration
Swift
public class AnyCancelable : Cancelable
extension AnyCancelable: Hashable
-
MapboxRecorder provides functions to record and replay API calls of a
MapboxMap
instance. These recordings can be used to debug issues which require multiple steps to reproduce. Additionally, playbacks can be used for performance testing custom scenarios.Note
The file format produced by MapRecorder is experimental and there is no guarantee for version cross-compatibility. The set of recorded APIs and their parameters might change in future releases.Declaration
Swift
@_spi(Experimental) public final class MapRecorder
-
Style provides access to the APIs used to dynamically modify the map’s style. Use it to read and write layers, sources, and images. Obtain the Style instance for a MapView via MapView.mapboxMap.style.
Important
Style should only be used from the main thread.Declaration
Swift
public class StyleManager
-
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 ViewportManager