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 feature labels. These features can come from vector tiles loaded by an MGLVectorTileSource object, or they can be MGLShape or MGLFeature instances in an MGLShapeSource or MGLComputedShapeSource 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:].

See the Dynamically style interactive points and Use images to cluster point data examples learn how to style data on your map using this layer.

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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *iconIgnoresPlacement;

    Swift

    var iconIgnoresPlacement: NSExpression! { get set }
  • Name of a style image to use for drawing an image background.

    Use the +[MGLStyle setImage:forName:] method to associate an image with a name that you can set this property to.

    Within a constant string value, a feature attribute name enclosed in curly braces (e.g., {token}) is replaced with the value of the named attribute. Tokens inside non-constant expressions are ignored; instead, use mgl_join: 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

    See the Use images to cluster point data example to learn how to dynamically set your icons with an expression.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite, 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 upward. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isIconOptional, 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 2. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 or line-center, 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 or line-center, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *iconScale;

    Swift

    var iconScale: NSExpression! { get set }
  • The directions in which the icon stretches to fit around the text. If the icon image is a resizable image, the resizable areas may be stretched, while the cap insets are always drawn at the original scale.

    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 (nonatomic, assign, unsafe_unretained, readwrite, 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 NSEdgeInsetsZero. 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 NSEdgeInsets 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 either MGLSymbolPlacementLine or MGLSymbolPlacementLineCenter. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 either MGLSymbolPlacementLine or MGLSymbolPlacementLineCenter. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 45. 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 either MGLSymbolPlacementLine or MGLSymbolPlacementLineCenter. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 10. 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *maximumTextWidth;

    Swift

    var maximumTextWidth: NSExpression! { get set }
  • Whether symbols in this layer avoid colliding with symbols in adjacent tiles.

    If this property is set to true, symbols in this layer avoid crossing the edge of a tile. You should set this property to true if the backing vector tiles don’t have enough padding to prevent collisions, or if this layer’s symbolPlacement property is set to MGLSymbolPlacementPoint but this layer is above a symbol layer whose symbolPlacement property is set to MGLSymbolPlacementLine. You do not need to enable this property to prevent clipped labels at tile boundaries.

    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 (nonatomic, assign, unsafe_unretained, readwrite, 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.
      • line-center: The label is placed at the center of the line of the geometry. Can only be used on LineString and Polygon geometries. Note that a single feature in a vector tile may contain multiple line 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *symbolPlacement;

    Swift

    var symbolPlacement: NSExpression! { get set }
  • Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When iconAllowsOverlap or textAllowsOverlap is false, features with a lower sort key will have priority during placement. When iconAllowsOverlap or textAllowsOverlap is set to YES, features with a higher sort key will overlap over features with a lower sort key.

    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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *symbolSortKey;

    Swift

    var symbolSortKey: 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 250. 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *symbolSpacing;

    Swift

    var symbolSpacing: NSExpression! { get set }
  • Controls the order in which overlapping symbols in the same layer are rendered

    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.

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

    • Constant MGLSymbolZOrder values
    • Any of the following constant string values:
      • auto: If symbol-sort-key is set, sort based on that. Otherwise sort symbols by their y-position relative to the viewport.
      • viewport-y: Specify this z order if symbols’ appearance relies on lower features overlapping higher features. For example, symbols with a pin-like appearance would require this z order.
      • source: Specify this z order if the order in which features appear in the source is significant.
    • 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *symbolZOrder;

    Swift

    var symbolZOrder: NSExpression! { get set }
  • Value to use for a text label.

    Within a constant string value, a feature attribute name enclosed in curly braces (e.g., {token}) is replaced with the value of the named attribute. Tokens inside non-constant expressions are ignored; instead, use mgl_join: 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
    • Formatted expressions.
    • 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

    See the Cluster point data and Use images to cluster point data to learn how to use an expression to set this attribute to the number of markers within a cluster.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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, and textVariableAnchor is set to 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 16. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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:
      • auto: The text is aligned towards the anchor position.
      • 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 upward. 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 textRadialOffset is set to 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isTextOptional, 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 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 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *textPitchAlignment;

    Swift

    var textPitchAlignment: NSExpression! { get set }
  • Radial offset of text, in the direction of the symbol’s anchor. Useful in combination with textVariableAnchor, which defaults to using the two-dimensional textOffset if present.

    This property is measured in ems.

    The default value of this property is an expression that evaluates to the float 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *textRadialOffset;

    Swift

    var textRadialOffset: 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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 or line-center, 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 or line-center, 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *textTransform;

    Swift

    var textTransform: NSExpression! { get set }
  • To increase the chance of placing high-priority labels on the map, you can provide an array of textAnchor locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use textJustify: auto to choose justification based on anchor position. To apply an offset, use the textRadialOffset or the two-dimensional textOffset.

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

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

    • Constant MGLTextAnchor array values
    • Constant array, in which each element is 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
    • 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *textVariableAnchor;

    Swift

    var textVariableAnchor: NSExpression! { get set }
  • The property allows control over a symbol’s orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single ‘vertical’ enum value. The order of elements in an array define priority order for the placement of an orientation variant.

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

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

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

    • Constant MGLTextWritingMode array values
    • Constant array, in which each element is any of the following constant string values:
      • horizontal: If a text’s language supports horizontal writing mode, symbols with point placement would be laid out horizontally.
      • vertical: If a text’s language supports vertical writing mode, symbols with point placement would be laid out vertically.
    • 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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *textWritingModes;

    Swift

    var textWritingModes: 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 NSColor.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 NSColor 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 NSColor.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 NSColor 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 upward. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 (nonatomic, assign, unsafe_unretained, readwrite, 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 NSColor.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 NSColor 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 NSColor.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 NSColor 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 0. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 upward. 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 (nonatomic, assign, unsafe_unretained, readwrite, 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 (nonatomic, assign, unsafe_unretained, readwrite)
        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 (nonatomic, assign, unsafe_unretained, readwrite, null_resettable)
        NSExpression *textTranslationAnchor;

    Swift

    var textTranslationAnchor: NSExpression! { get set }