AnnotationManager
public class AnnotationManager : Observer
Manages the addition, update, and the deletion of annotations to a map.
All annotations added with this class belong to a single source and style layer.
-
Undocumented
Declaration
Swift
public var peer: MBXPeerWrapper?
-
A dictionary of key/value pairs being managed by the
AnnotationManager, where the key represents the unique identifier of the annotation and the value refers to theAnnotationitself.Note
This property is get-only, so it cannot be used to add or remove annotations. Instead, use theaddAnnotationorremoveAnnotationrelated methods update annotations belonging to the map view.Declaration
Swift
public private(set) var annotations: [String : Annotation] { get } -
The delegate to notify of changes in annotations.
Declaration
Swift
public weak var interactionDelegate: AnnotationInteractionDelegate? -
An array of annotations that have currently been selected by the annotation manager.
Declaration
Swift
public var selectedAnnotations: [Annotation] { get } -
A
Boolvalue that indicates whether users can interact with the annotations managed by the annotation manager. The default value istrue. Setting this property tofalsewill deinitialize the annotation manager’s tap gesture recognizer.Declaration
Swift
public var userInteractionEnabled: Bool { get set }
-
Adds a given annotation to the
MapView.If the given annotation has already been added to the
MapView, this returns an error.Declaration
Swift
@discardableResult public func addAnnotation(_ annotation: Annotation) -> Result<Bool, AnnotationError>Parameters
annotationAnnotation to add to the
MapView.Return Value
If operation successful, returns a
trueas part of theResultsuccess case. Else, returns aAnnotationErrorin theResultfailure case. -
Adds a given array of annotations to the
MapView.The method is equivalent to calling
addAnnotation(_ annotation:)method for each annotation within the group.Declaration
Swift
@discardableResult public func addAnnotations(_ annotations: [Annotation]) -> Result<Bool, AnnotationError>Parameters
annotationsAnnotations to add to the
MapView. -
Updates the annotation registered with the annotation manager.
Throws
AnnotationError.annotationDoesNotExistif the annotation hasn’t been added, otherwise throwsAnnotationError.updateAnnotationFailed.Declaration
Swift
public func updateAnnotation(_ annotation: Annotation) throwsParameters
annotationThe annotation that should be updated.
-
Removes a given annotation from the
MapView.If the given annotation has already been removed from the
MapView, this returns an error.Declaration
Swift
@discardableResult public func removeAnnotation(_ annotation: Annotation) -> Result<Bool, AnnotationError>Parameters
annotationAnnotation to remove from the
MapView.Return Value
If operation successful, returns a
trueas part of theResultsuccess case. Else, returns aAnnotationErrorin theResultfailure case. -
Removes a given array of annotations from the
MapView.The method is equivalent to calling
removeAnnotation(_ annotation:)method for each annotation within the group.Declaration
Swift
@discardableResult public func removeAnnotations(_ annotations: [Annotation]) -> Result<Bool, AnnotationError>Parameters
annotationsAnnotations to remove from the
MapView. -
Toggles the annotation’s selection state. If the annotation is deselected, it becomes selected. If the annotation is selected, it becomes deselected.
Declaration
Swift
public func selectAnnotation(_ annotation: Annotation)Parameters
AnnotationsThe annotation to select.
-
Undocumented
See moreDeclaration
Swift
public enum AnnotationError : Error -
Undocumented
Declaration
Swift
public func notify(for event: MapboxCoreMaps.Event)
AnnotationManager Class Reference