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 theAnnotation
itself.Note
This property is get-only, so it cannot be used to add or remove annotations. Instead, use theaddAnnotation
orremoveAnnotation
related 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
Bool
value that indicates whether users can interact with the annotations managed by the annotation manager. The default value istrue
. Setting this property tofalse
will 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
annotation
Annotation to add to the
MapView
.Return Value
If operation successful, returns a
true
as part of theResult
success case. Else, returns aAnnotationError
in theResult
failure 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
annotations
Annotations to add to the
MapView
. -
Updates the annotation registered with the annotation manager.
Throws
AnnotationError.annotationDoesNotExist
if the annotation hasn’t been added, otherwise throwsAnnotationError.updateAnnotationFailed
.Declaration
Swift
public func updateAnnotation(_ annotation: Annotation) throws
Parameters
annotation
The 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
annotation
Annotation to remove from the
MapView
.Return Value
If operation successful, returns a
true
as part of theResult
success case. Else, returns aAnnotationError
in theResult
failure 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
annotations
Annotations 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
Annotations
The annotation to select.
-
Undocumented
See moreDeclaration
Swift
public enum AnnotationError : Error
-
Undocumented
Declaration
Swift
public func notify(for event: MapboxCoreMaps.Event)