MGLSymbolAnnotationController
@interface MGLSymbolAnnotationController : MGLAnnotationController
An MGLSymbolAnnotationController is a controller that creates internally
instances of an MGLShapeSource and MGLSymbolStyleLayer to simplify the creation
of runtime styling based annotations to the map.
Create instances of MGLSymbolStyleAnnotation and pass it to this controller.
An image must be supplied to the map style’s sprite before being able to assign it to be the icon image of a symbol.
Example
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
let attraction = UIImage(named: "attraction")
if let styleImage = attraction {
self.mapView.style?.setImage(styleImage, forName: "attraction")
}
let symbolAnnotationController = MGLSymbolAnnotationController(mapView: self.mapView)
let symbol = MGLSymbolStyleAnnotation(coordinate: CLLocationCoordinate2DMake(59, 18));
symbol.iconImageName = "attraction"
symbol.text = "This is a cool place!"
symbol.textFontSize = 16
symbolAnnotationController.add(symbol)
}
-
If true, the icon will be visible even if it collides with other previously drawn symbols. Requires
iconImageName. Defaults toNO.This property corresponds to the
icon-allow-overlapproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL iconAllowsOverlap;Swift
var iconAllowsOverlap: Bool { get set } -
If true, other symbols can be visible even if they collide with the icon. Requires
iconImageName. Defaults toNO.This property corresponds to the
icon-ignore-placementproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL iconIgnoresPlacement;Swift
var iconIgnoresPlacement: Bool { get set } -
If true, text will display without their corresponding icons only when the icon collides with other symbols and the text does not. Requires
iconImageName. Defaults toNO.This property corresponds to the
icon-optionalproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL iconOptional;Swift
var iconOptional: Bool { get set } -
The size of the additional area around the icon’s bounding box used for detecting symbol collisions. Requires
iconImageName. Defaults to aCGFloatwith a value of2.This property corresponds to the
icon-paddingproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat iconPadding;Swift
var iconPadding: Int32 { get set } -
The orientation of the style annotation’s icon when map is pitched, as defined by
MGLIconPitchAlignment. RequiresiconImageName. Defaults toauto.This property corresponds to the
icon-pitch-alignmentproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int iconPitchAlignment;Swift
var iconPitchAlignment: Int32 { get set } -
Determines the rotation behavior of icons, in combination with
symbolPlacementas defined byMGLIconRotationAlignment. RequiresiconImageName. Defaults toauto.This property corresponds to the
icon-pitch-alignmentproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int iconRotationAlignment;Swift
var iconRotationAlignment: Int32 { get set } -
Scales the icon to fit around the associated text, as defined by
MGLIconTextFit. RequiresiconImageNameandtext. Defaults tonone.This property corresponds to the
icon-text-fitproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int iconTextFit;Swift
var iconTextFit: Int32 { get set } -
The size of the additional area added to dimensions determined by
iconTextFit. Defaults toUIEdgeInsetsZero.This property corresponds to the
icon-text-fit-paddingproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) UIEdgeInsets iconTextFitPadding;Swift
var iconTextFitPadding: Int32 { get set } -
If true, the icon may be flipped to prevent it from being rendered upside-down. Requires
iconImageName. RequiresiconRotationAlignmentto be set tomap. Defaults toNO.This property corresponds to the
icon-keep-uprightproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL keepsIconUpright;Swift
var keepsIconUpright: Bool { get set } -
If true, the text may be flipped vertically to prevent it from being rendered upside-down. Requires
text. RequirestextRotationAlignmentto be set tomap. Defaults toYES.This property corresponds to the
text-keep-uprightproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL keepsTextUpright;Swift
var keepsTextUpright: Bool { get set } -
Maximum angle change between adjacent characters, measured in degrees. Requires
text. RequiressymbolPlacementto be set tolineorcenter. Defaults to45degrees.This property corresponds to the
text-max-angleproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat maximumTextAngle;Swift
var maximumTextAngle: Int32 { get set } -
If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don’t have enough padding in the vector tile to prevent collisions.
This property corresponds to the
symbol-avoid-edges)property in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL symbolAvoidsEdges;Swift
var symbolAvoidsEdges: Bool { get set } -
The placement of the symbol annotation’s text relative to its geometry, as defined by
MGLSymbolPlacement. Defaults topoint.This property corresponds to the
symbol-placementproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int symbolPlacement;Swift
var symbolPlacement: Int32 { get set } -
Distance between two symbol anchors, measured in screen points. Requires
symbolPlacementto be set toline. Defaults to aCGFloatthat evaluates to250.This property corresponds to the
symbol-spacingproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat symbolSpacing;Swift
var symbolSpacing: Int32 { get set } -
Controls the order in which overlapping symbol style annotations in the same
MGLSymbolAnnotationControllerare rendered, as defined byMGLSymbolZOrder. Defaults toauto.This property corresponds to the
symbol-z-orderproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int symbolZOrder;Swift
var symbolZOrder: Int32 { get set } -
If true, the symbol style annotation’s text will be visible even if it collides with other previously drawn symbol style annotations. Requires
text. Defaults toNO.This property corresponds to the
text-allow-overlapproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL textAllowsOverlap;Swift
var textAllowsOverlap: Bool { get set } -
Text leading value for multi-line text, measured in ems. Requires
text. Defaults to aCGFloatthat evaluates to1.2.This property corresponds to the
text-line-heightproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat textLineHeight;Swift
var textLineHeight: Int32 { get set } -
If true, symbol style annotation icons will display without their corresponding text if the text collides with other symbols and the icon does not. Requires
iconImageNameandtext. Defaults toNO.This property corresponds to the
text-optionalproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) BOOL textOptional;Swift
var textOptional: Bool { get set } -
The size of the additional area around the text bounding box used for detecting symbol collisions, measured in screen points greater than or equal to zero. Requires
text. Defaults to aCGFloatthat evaluates to2.This property corresponds to the
text-paddingproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat textPadding;Swift
var textPadding: Int32 { get set } -
The orientation of the symbol style annotation’s text when map is pitched, as defined by
MGLTextPitchAlignment. Requirestext. Defaults toauto.This property corresponds to the
text-pitch-alignmentproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int textPitchAlignment;Swift
var textPitchAlignment: Int32 { get set } -
Determines the rotation behavior of the individual glyphs forming the text, in combination with
symbolPlacementand defined byMGLTextRotationAlignment. Requirestext. Defaults toauto.This property corresponds to the
text-rotation-alignmentproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int textRotationAlignment;Swift
var textRotationAlignment: Int32 { get set } -
Determines the best placement for the text of multiple symbol style annotations given an array of preferred
MGLTextAnchorvalues. This allows the renderer to auto-select a uniquetextAnchorfor each symbol style annotation. RequiressymbolPlacementto be set topoint. Disabled bytextOffsetandtextAnchor. Not set by default.This property corresponds to the
text-variable-anchorproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) NSArray<NSString *> *_Nonnull textVariableAnchor;Swift
unowned(unsafe) var textVariableAnchor: NSArray { get set } -
The distance that the icon anchor of the symbol style annotation is moved from its original placement, measured in screen points. Requires
iconImageName. Defaults to aCGVectorstruct set to 0 points rightward and 0 points downward.This property corresponds to the
icon-translateproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGVector iconTranslation;Swift
var iconTranslation: Int32 { get set } -
Controls the frame of reference for
iconTranslation, as defined byMGLIconTranslationAnchor. RequiresiconImageName. Defaults tomap.This property corresponds to the
icon-translate-anchorproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int iconTranslationAnchor;Swift
var iconTranslationAnchor: Int32 { get set } -
The distance that the text anchor of the symbol style annotation is moved from its original placement, measured in screen points. Requires
text. Defaults to aCGVectorstruct set to 0 points rightward and 0 points downward.This property corresponds to the
text-translateproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGVector textTranslation;Swift
var textTranslation: Int32 { get set } -
Controls the frame of reference for
textTranslation, as defined byMGLTextTranslationAnchor. Requirestext. Defaults tomap.This property corresponds to the
text-translate-anchorproperty in the style Mapbox Style Specification.Declaration
Objective-C
@property (assign, readwrite, nonatomic) int textTranslationAnchor;Swift
var textTranslationAnchor: Int32 { get set }
MGLSymbolAnnotationController Class Reference