MGLSymbolStyleLayer


@interface MGLSymbolStyleLayer : MGLVectorStyleLayer

An MGLSymbolStyleLayer is a style layer that renders icon and text labels at points or along lines on the map.

Use a symbol style layer to configure the visual appearance of labels for features in vector tiles loaded by an MGLVectorSource object or MGLShape or MGLFeature instances in an MGLShapeSource object.

You can access an existing symbol style layer using the -[MGLStyle layerWithIdentifier:] method if you know its identifier; otherwise, find it using the MGLStyle.layers property. You can also create a new symbol style layer and add it to the style using a method such as -[MGLStyle addLayer:].

Example

let layer = MGLSymbolStyleLayer(identifier: "coffeeshops", source: pois)
layer.sourceLayerIdentifier = "pois"
layer.iconImageName = NSExpression(forConstantValue: "coffee")
layer.iconScale = NSExpression(forConstantValue: 0.5)
layer.text = NSExpression(forKeyPath: "name")
layer.textTranslation = NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: 10, dy: 0)))
layer.textJustification = NSExpression(forConstantValue: "left")
layer.textAnchor = NSExpression(forConstantValue: "left")
layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee")
mapView.style?.addLayer(layer)
  • Returns a symbol style layer initialized with an identifier and source.

    After initializing and configuring the style layer, add it to a map view’s style using the -[MGLStyle addLayer:] or -[MGLStyle insertLayer:belowLayer:] method.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithIdentifier:(nonnull NSString *)identifier
                                        source:(nonnull MGLSource *)source;

    Swift

    init(identifier: String, source: MGLSource)

    Parameters

    identifier

    A string that uniquely identifies the source in the style to which it is added.

    source

    The source from which to obtain the data to style. If the source has not yet been added to the current style, the behavior is undefined.

    Return Value

    An initialized foreground style layer.

  • If true, the icon will be visible even if it collides with other previously drawn symbols.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the icon-allow-overlap layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconAllowsOverlap;

    Swift

    var iconAllowsOverlap: NSExpression! { get set }
  • Part of the icon placed closest to the anchor.

    The default value of this property is an expression that evaluates to center. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLIconAnchor values
    • Any of the following constant string values:
      • center: The center of the icon is placed closest to the anchor.
      • left: The left side of the icon is placed closest to the anchor.
      • right: The right side of the icon is placed closest to the anchor.
      • top: The top of the icon is placed closest to the anchor.
      • bottom: The bottom of the icon is placed closest to the anchor.
      • top-left: The top left corner of the icon is placed closest to the anchor.
      • top-right: The top right corner of the icon is placed closest to the anchor.
      • bottom-left: The bottom left corner of the icon is placed closest to the anchor.
      • bottom-right: The bottom right corner of the icon is placed closest to the anchor.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconAnchor;

    Swift

    var iconAnchor: NSExpression! { get set }
  • If true, other symbols can be visible even if they collide with the icon.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the icon-ignore-placement layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconIgnoresPlacement;

    Swift

    var iconIgnoresPlacement: NSExpression! { get set }
  • Name of image in sprite to use for drawing an image background. Within literal values, attribute names enclosed in curly brackets (e.g. {token}) are replaced with the value of the named attribute. Expressions do not support this syntax; for equivalent functionality in expressions, use stringByAppendingString: and key path expressions.

    This attribute corresponds to the icon-image layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant string values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconImageName;

    Swift

    var iconImageName: NSExpression! { get set }
  • Offset distance of icon from its anchor.

    The default value of this property is an expression that evaluates to an NSValue object containing a CGVector struct set to 0 rightward and 0 downward. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant CGVector values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconOffset;

    Swift

    var iconOffset: NSExpression! { get set }
  • If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil, and text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (getter=isIconOptional, assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconOptional;

    Swift

    var iconOptional: NSExpression! { get set }
  • Size of the additional area around the icon bounding box used for detecting symbol collisions.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconPadding;

    Swift

    var iconPadding: NSExpression! { get set }
  • Orientation of icon when map is pitched.

    The default value of this property is an expression that evaluates to auto. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLIconPitchAlignment values
    • Any of the following constant string values:
      • map: The icon is aligned to the plane of the map.
      • viewport: The icon is aligned to the plane of the viewport.
      • auto: Automatically matches the value of icon-rotation-alignment.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconPitchAlignment;

    Swift

    var iconPitchAlignment: NSExpression! { get set }
  • Rotates the icon clockwise.

    This property is measured in degrees.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the icon-rotate layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant numeric values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconRotation;

    Swift

    var iconRotation: NSExpression! { get set }
  • In combination with symbolPlacement, determines the rotation behavior of icons.

    The default value of this property is an expression that evaluates to auto. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLIconRotationAlignment values
    • Any of the following constant string values:
      • map: When symbol-placement is set to point, aligns icons east-west. When symbol-placement is set to line, aligns icon x-axes with the line.
      • viewport: Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbol-placement.
      • auto: When symbol-placement is set to point, this is equivalent to viewport. When symbol-placement is set to line, this is equivalent to map.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconRotationAlignment;

    Swift

    var iconRotationAlignment: NSExpression! { get set }
  • Scales the original size of the icon by the provided factor. The new point size of the image will be the original point size multiplied by iconScale. 1 is the original size; 3 triples the size of the image.

    This property is measured in factor of the original icon sizes.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the icon-size layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconScale;

    Swift

    var iconScale: NSExpression! { get set }
  • Scales the icon to fit around the associated text.

    The default value of this property is an expression that evaluates to none. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil, and text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLIconTextFit values
    • Any of the following constant string values:
      • none: The icon is displayed at its intrinsic aspect ratio.
      • width: The icon is scaled in the x-dimension to fit the width of the text.
      • height: The icon is scaled in the y-dimension to fit the height of the text.
      • both: The icon is scaled in both x- and y-dimensions.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconTextFit;

    Swift

    var iconTextFit: NSExpression! { get set }
  • Size of the additional area added to dimensions determined by iconTextFit.

    This property is measured in points.

    The default value of this property is an expression that evaluates to an NSValue object containing UIEdgeInsetsZero. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil, and text is non-nil, and iconTextFit is set to an expression that evaluates to MGLIconTextFitBoth, MGLIconTextFitWidth, or MGLIconTextFitHeight. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant UIEdgeInsets values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconTextFitPadding;

    Swift

    var iconTextFitPadding: NSExpression! { get set }
  • If true, the icon may be flipped to prevent it from being rendered upside-down.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil, and iconRotationAlignment is set to an expression that evaluates to map, and symbolPlacement is set to an expression that evaluates to line. Otherwise, it is ignored.

    This attribute corresponds to the icon-keep-upright layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *keepsIconUpright;

    Swift

    var keepsIconUpright: NSExpression! { get set }
  • If true, the text may be flipped vertically to prevent it from being rendered upside-down.

    The default value of this property is an expression that evaluates to YES. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil, and textRotationAlignment is set to an expression that evaluates to map, and symbolPlacement is set to an expression that evaluates to line. Otherwise, it is ignored.

    This attribute corresponds to the text-keep-upright layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *keepsTextUpright;

    Swift

    var keepsTextUpright: NSExpression! { get set }
  • Maximum angle change between adjacent characters.

    This property is measured in degrees.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil, and symbolPlacement is set to an expression that evaluates to line. Otherwise, it is ignored.

    This attribute corresponds to the text-max-angle layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant numeric values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *maximumTextAngle;

    Swift

    var maximumTextAngle: NSExpression! { get set }
  • The maximum line width for text wrapping.

    This property is measured in ems.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-max-width layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *maximumTextWidth;

    Swift

    var maximumTextWidth: NSExpression! { 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, or if it is a point symbol layer placed after a line symbol layer.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This attribute corresponds to the symbol-avoid-edges layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *symbolAvoidsEdges;

    Swift

    var symbolAvoidsEdges: NSExpression! { get set }
  • Label placement relative to its geometry.

    The default value of this property is an expression that evaluates to point. Set this property to nil to reset it to the default value.

    You can set this property to an expression containing any of the following:

    • Constant MGLSymbolPlacement values
    • Any of the following constant string values:
      • point: The label is placed at the point where the geometry is located.
      • line: The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *symbolPlacement;

    Swift

    var symbolPlacement: NSExpression! { get set }
  • Distance between two symbol anchors.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if symbolPlacement is set to an expression that evaluates to line. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 1
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *symbolSpacing;

    Swift

    var symbolSpacing: NSExpression! { get set }
  • Value to use for a text label. Within literal values, attribute names enclosed in curly brackets (e.g. {token}) are replaced with the value of the named attribute. Expressions do not support this syntax; for equivalent functionality in expressions, use stringByAppendingString: and key path expressions.

    The default value of this property is an expression that evaluates to the empty string. Set this property to nil to reset it to the default value.

    This attribute corresponds to the text-field layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant string values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable) NSExpression *text;

    Swift

    var text: NSExpression! { get set }
  • If true, the text will be visible even if it collides with other previously drawn symbols.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-allow-overlap layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textAllowsOverlap;

    Swift

    var textAllowsOverlap: NSExpression! { get set }
  • Part of the text placed closest to the anchor.

    The default value of this property is an expression that evaluates to center. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLTextAnchor values
    • Any of the following constant string values:
      • center: The center of the text is placed closest to the anchor.
      • left: The left side of the text is placed closest to the anchor.
      • right: The right side of the text is placed closest to the anchor.
      • top: The top of the text is placed closest to the anchor.
      • bottom: The bottom of the text is placed closest to the anchor.
      • top-left: The top left corner of the text is placed closest to the anchor.
      • top-right: The top right corner of the text is placed closest to the anchor.
      • bottom-left: The bottom left corner of the text is placed closest to the anchor.
      • bottom-right: The bottom right corner of the text is placed closest to the anchor.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textAnchor;

    Swift

    var textAnchor: NSExpression! { get set }
  • An array of font face names used to display the text.

    Each font name must be included in the {fontstack} portion of the JSON stylesheet’s glyphs property. You can register a custom font when designing the style in Mapbox Studio. Fonts installed on the system are not used.

    The first font named in the array is applied to the text. For each character in the text, if the first font lacks a glyph for the character, the next font is applied as a fallback, and so on.

    The default value of this property is an expression that evaluates to the array Open Sans Regular, Arial Unicode MS Regular. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-font layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant array values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textFontNames;

    Swift

    var textFontNames: NSExpression! { get set }
  • Font size.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-size layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textFontSize;

    Swift

    var textFontSize: NSExpression! { get set }
  • If true, other symbols can be visible even if they collide with the text.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-ignore-placement layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textIgnoresPlacement;

    Swift

    var textIgnoresPlacement: NSExpression! { get set }
  • Text justification options.

    The default value of this property is an expression that evaluates to center. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-justify layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant MGLTextJustification values
    • Any of the following constant string values:
      • left: The text is aligned to the left.
      • center: The text is centered.
      • right: The text is aligned to the right.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textJustification;

    Swift

    var textJustification: NSExpression! { get set }
  • Text tracking amount.

    This property is measured in ems.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textLetterSpacing;

    Swift

    var textLetterSpacing: NSExpression! { get set }
  • Text leading value for multi-line text.

    This property is measured in ems.

    The default value of this property is an expression that evaluates to the float 1.2. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textLineHeight;

    Swift

    var textLineHeight: NSExpression! { get set }
  • Offset distance of text from its anchor.

    This property is measured in ems.

    The default value of this property is an expression that evaluates to an NSValue object containing a CGVector struct set to 0 ems rightward and 0 ems downward. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant CGVector values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textOffset;

    Swift

    var textOffset: NSExpression! { get set }
  • If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.

    The default value of this property is an expression that evaluates to NO. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil, and iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant Boolean values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (getter=isTextOptional, assign, readwrite, nonatomic, null_resettable)
        NSExpression *textOptional;

    Swift

    var textOptional: NSExpression! { get set }
  • Size of the additional area around the text bounding box used for detecting symbol collisions.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textPadding;

    Swift

    var textPadding: NSExpression! { get set }
  • Orientation of text when map is pitched.

    The default value of this property is an expression that evaluates to auto. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLTextPitchAlignment values
    • Any of the following constant string values:
      • map: The text is aligned to the plane of the map.
      • viewport: The text is aligned to the plane of the viewport.
      • auto: Automatically matches the value of text-rotation-alignment.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textPitchAlignment;

    Swift

    var textPitchAlignment: NSExpression! { get set }
  • Rotates the text clockwise.

    This property is measured in degrees.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-rotate layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant numeric values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textRotation;

    Swift

    var textRotation: NSExpression! { get set }
  • In combination with symbolPlacement, determines the rotation behavior of the individual glyphs forming the text.

    The default value of this property is an expression that evaluates to auto. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLTextRotationAlignment values
    • Any of the following constant string values:
      • map: When symbol-placement is set to point, aligns text east-west. When symbol-placement is set to line, aligns text x-axes with the line.
      • viewport: Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of symbol-placement.
      • auto: When symbol-placement is set to point, this is equivalent to viewport. When symbol-placement is set to line, this is equivalent to map.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textRotationAlignment;

    Swift

    var textRotationAlignment: NSExpression! { get set }
  • Specifies how to capitalize text.

    The default value of this property is an expression that evaluates to none. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant MGLTextTransform values
    • Any of the following constant string values:
      • none: The text is not altered.
      • uppercase: Forces all letters to be displayed in uppercase.
      • lowercase: Forces all letters to be displayed in lowercase.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textTransform;

    Swift

    var textTransform: NSExpression! { get set }
  • The tint color to apply to the icon. The iconImageName property must be set to a template image.

    The default value of this property is an expression that evaluates to UIColor.blackColor. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant UIColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconColor;

    Swift

    var iconColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s iconColor property.

    This property corresponds to the icon-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition iconColorTransition;

    Swift

    var iconColorTransition: MGLTransition { get set }
  • Fade out the halo towards the outside.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconHaloBlur;

    Swift

    var iconHaloBlur: NSExpression! { get set }
  • The transition affecting any changes to this layer’s iconHaloBlur property.

    This property corresponds to the icon-halo-blur-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition iconHaloBlurTransition;

    Swift

    var iconHaloBlurTransition: MGLTransition { get set }
  • The color of the icon’s halo. The iconImageName property must be set to a template image.

    The default value of this property is an expression that evaluates to UIColor.clearColor. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant UIColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconHaloColor;

    Swift

    var iconHaloColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s iconHaloColor property.

    This property corresponds to the icon-halo-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition iconHaloColorTransition;

    Swift

    var iconHaloColorTransition: MGLTransition { get set }
  • Distance of halo to the icon outline.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconHaloWidth;

    Swift

    var iconHaloWidth: NSExpression! { get set }
  • The transition affecting any changes to this layer’s iconHaloWidth property.

    This property corresponds to the icon-halo-width-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition iconHaloWidthTransition;

    Swift

    var iconHaloWidthTransition: MGLTransition { get set }
  • The opacity at which the icon will be drawn.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values between 0 and 1 inclusive
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconOpacity;

    Swift

    var iconOpacity: NSExpression! { get set }
  • The transition affecting any changes to this layer’s iconOpacity property.

    This property corresponds to the icon-opacity-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition iconOpacityTransition;

    Swift

    var iconOpacityTransition: MGLTransition { get set }
  • Distance that the icon’s anchor is moved from its original placement.

    This property is measured in points.

    The default value of this property is an expression that evaluates to an NSValue object containing a CGVector struct set to 0 points rightward and 0 points downward. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the icon-translate layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant CGVector values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconTranslation;

    Swift

    var iconTranslation: NSExpression! { get set }
  • The transition affecting any changes to this layer’s iconTranslation property.

    This property corresponds to the icon-translate-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition iconTranslationTransition;

    Swift

    var iconTranslationTransition: MGLTransition { get set }
  • Controls the frame of reference for iconTranslation.

    The default value of this property is an expression that evaluates to map. Set this property to nil to reset it to the default value.

    This property is only applied to the style if iconImageName is non-nil, and iconTranslation is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the icon-translate-anchor layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant MGLIconTranslationAnchor values
    • Any of the following constant string values:
      • map: Icons are translated relative to the map.
      • viewport: Icons are translated relative to the viewport.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *iconTranslationAnchor;

    Swift

    var iconTranslationAnchor: NSExpression! { get set }
  • The color with which the text will be drawn.

    The default value of this property is an expression that evaluates to UIColor.blackColor. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant UIColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textColor;

    Swift

    var textColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s textColor property.

    This property corresponds to the text-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition textColorTransition;

    Swift

    var textColorTransition: MGLTransition { get set }
  • The halo’s fadeout distance towards the outside.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textHaloBlur;

    Swift

    var textHaloBlur: NSExpression! { get set }
  • The transition affecting any changes to this layer’s textHaloBlur property.

    This property corresponds to the text-halo-blur-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition textHaloBlurTransition;

    Swift

    var textHaloBlurTransition: MGLTransition { get set }
  • The color of the text’s halo, which helps it stand out from backgrounds.

    The default value of this property is an expression that evaluates to UIColor.clearColor. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant UIColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textHaloColor;

    Swift

    var textHaloColor: NSExpression! { get set }
  • The transition affecting any changes to this layer’s textHaloColor property.

    This property corresponds to the text-halo-color-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition textHaloColorTransition;

    Swift

    var textHaloColorTransition: MGLTransition { get set }
  • Distance of halo to the font outline. Max text halo width is ¼ of the font-size.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values no less than 0
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textHaloWidth;

    Swift

    var textHaloWidth: NSExpression! { get set }
  • The transition affecting any changes to this layer’s textHaloWidth property.

    This property corresponds to the text-halo-width-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition textHaloWidthTransition;

    Swift

    var textHaloWidthTransition: MGLTransition { get set }
  • The opacity at which the text will be drawn.

    The default value of this property is an expression that evaluates to the float

    1. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    You can set this property to an expression containing any of the following:

    • Constant numeric values between 0 and 1 inclusive
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable and/or feature attributes

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textOpacity;

    Swift

    var textOpacity: NSExpression! { get set }
  • The transition affecting any changes to this layer’s textOpacity property.

    This property corresponds to the text-opacity-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition textOpacityTransition;

    Swift

    var textOpacityTransition: MGLTransition { get set }
  • Distance that the text’s anchor is moved from its original placement.

    This property is measured in points.

    The default value of this property is an expression that evaluates to an NSValue object containing a CGVector struct set to 0 points rightward and 0 points downward. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-translate layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant CGVector values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

    This property does not support applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textTranslation;

    Swift

    var textTranslation: NSExpression! { get set }
  • The transition affecting any changes to this layer’s textTranslation property.

    This property corresponds to the text-translate-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MGLTransition textTranslationTransition;

    Swift

    var textTranslationTransition: MGLTransition { get set }
  • Controls the frame of reference for textTranslation.

    The default value of this property is an expression that evaluates to map. Set this property to nil to reset it to the default value.

    This property is only applied to the style if text is non-nil, and textTranslation is non-nil. Otherwise, it is ignored.

    This attribute corresponds to the text-translate-anchor layout property in the Mapbox Style Specification.

    You can set this property to an expression containing any of the following:

    • Constant MGLTextTranslationAnchor values
    • Any of the following constant string values:
      • map: The text is translated relative to the map.
      • viewport: The text is translated relative to the viewport.
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Step functions applied to the $zoomLevel variable

    This property does not support applying interpolation functions to the $zoomLevel variable or applying interpolation or step functions to feature attributes.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, null_resettable)
        NSExpression *textTranslationAnchor;

    Swift

    var textTranslationAnchor: NSExpression! { get set }