MGLAnnotationController
@interface MGLAnnotationController : NSObject
An MGLStyleAnnotationController
is the object responsible for adding, removing, and updating
MGLStyleAnnotation
s 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
MGLMapView
associated with the style annotation controller.Declaration
Objective-C
@property (nonatomic, strong) MGLMapView *mapView
Swift
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
mapView
The
MGLMapView
the 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
mapView
The
MGLMapView
the that style annotations should be added to.layerIdentifier
The 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
styleAnnotation
The
MGLStyleAnnotation
that 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
styleAnnotations
An array of
MGLStyleAnnotation
s 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
styleAnnotation
The
MGLStyleAnnotation
that 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
styleAnnotations
An array of
MGLStyleAnnotation
s 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
styleAnnotation
The
MGLStyleAnnotation
that 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
styleAnnotations
An array of
MGLStyleAnnotation
s that should be updated. -
Selects the style annotation programmatically.
Declaration
Objective-C
- (void)selectStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;
Swift
func selectStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)
Parameters
styleAnnotation
The
MGLStyleAnnotation
to be selected. -
Deselects the style annotation programmatically.
Declaration
Objective-C
- (void)deselectStyleAnnotation:(nonnull MGLStyleAnnotation *)styleAnnotation;
Swift
func deselectStyleAnnotation(_ styleAnnotation: MGLStyleAnnotation)
Parameters
styleAnnotation
The
MGLStyleAnnotation
to 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]