MGLAnnotationController
@interface MGLAnnotationController : NSObject
An MGLStyleAnnotationController is the object responsible for adding, removing, and updating
MGLStyleAnnotations on a map.
Do not create instances of MGLStyleAnnotationController directly. Instead, create an instance of
MGLCircleAnnotationController, MGLLineAnnotationController, MGLPolygonAnnotationController, or
MGLSymbolAnnotationController and use -[MGLAnnotationController addShape:] or
-[MGLStyleAnnotationController addShapes:] to add shapes to an MGLMapView.
-
A boolean indicating whether style annotations belonging to the controller should support callouts when the user taps on them.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL annotationsInteractionEnabled;Swift
var annotationsInteractionEnabled: Bool { get set } -
The
MGLMapViewassociated with the style annotation controller.Declaration
Objective-C
@property (nonatomic, strong) MGLMapView *mapViewSwift
var mapView: UnsafeMutablePointer<Int32> { get set } -
The receiver’s delegate.
An annotation controller sends messages to its delegate to notify when a style annotation is selected/deselected.
Declaration
Objective-C
@property (readwrite, nonatomic, nullable) id<MGLAnnotationControllerDelegate> delegate;Swift
weak var delegate: MGLAnnotationControllerDelegate? { get set } -
Returns a new style annotation controller for the specified map view.
Declaration
Objective-C
- (nonnull instancetype)initWithMapView:(id)mapView;Swift
init(mapView: Any!)Parameters
mapViewThe
MGLMapViewthe that style annotations should be added to.Return Value
An initialized style annotation controller.
-
Returns a new style annotation controller for the specified map view, that will be capable of adding style annotations below a given style layer within a
MGLStyle.Declaration
Objective-C
- (nonnull instancetype)initWithMapView:(id)mapView belowLayerIdentifier:(nonnull NSString *)layerIdentifier;Swift
init(mapView: Any!, belowLayerIdentifier layerIdentifier: String)Parameters
mapViewThe
MGLMapViewthe that style annotations should be added to.layerIdentifierThe unique string identifier representing the layer at which style annotations can be inserted under.
Return Value
An initialized style annotation controller.
-
Adds a single style annotation to the
MGLMapView.Declaration
Objective-C
- (void)addStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;Swift
func addStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)Parameters
styleAnnotationThe
MGLStyleAnnotationthat should be added. -
Adds multiple style annotations to the
MGLMapView.Declaration
Objective-C
- (void)addStyleAnnotations: (nonnull NSArray<MGLStyleAnnotation *> *)styleAnnotations;Swift
func addStyleAnnotations(_ styleAnnotations: [MGLStyleAnnotation])Parameters
styleAnnotationsAn array of
MGLStyleAnnotations that should be added to theMGLMapView. -
Removes a single style annotation from the
MGLMapView.Declaration
Objective-C
- (void)removeStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;Swift
func removeStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)Parameters
styleAnnotationThe
MGLStyleAnnotationthat should be removed. -
Removes multiple style annotation from the
MGLMapView.Declaration
Objective-C
- (void)removeStyleAnnotations: (nonnull NSArray<MGLStyleAnnotation *> *)styleAnnotations;Swift
func removeStyleAnnotations(_ styleAnnotations: [MGLStyleAnnotation])Parameters
styleAnnotationsAn array of
MGLStyleAnnotations that should be removed from theMGLMapView. -
Updates a single style annotation on the
MGLMapView.Declaration
Objective-C
- (void)updateStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;Swift
func updateStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)Parameters
styleAnnotationThe
MGLStyleAnnotationthat should be updated. -
Updates multiple style annotationa on the
MGLMapView.Declaration
Objective-C
- (void)updateStyleAnnotations: (nonnull NSArray<MGLStyleAnnotation *> *)styleAnnotations;Swift
func updateStyleAnnotations(_ styleAnnotations: [MGLStyleAnnotation])Parameters
styleAnnotationsAn array of
MGLStyleAnnotations that should be updated. -
Selects the style annotation programmatically.
Declaration
Objective-C
- (void)selectStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;Swift
func selectStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)Parameters
styleAnnotationThe
MGLStyleAnnotationto be selected. -
Deselects the style annotation programmatically.
Declaration
Objective-C
- (void)deselectStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;Swift
func deselectStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)Parameters
styleAnnotationThe
MGLStyleAnnotationto be deselected. -
Returns the style annotations added to the controller.
Objects returned may not be in the same order as they were added.
Declaration
Objective-C
- (nonnull NSArray<MGLStyleAnnotation *> *)styleAnnotations;Swift
func styleAnnotations() -> [MGLStyleAnnotation]
MGLAnnotationController Class Reference