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:]
.
Related examples
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 tonil
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 tonil
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 }
- Constant
-
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 tonil
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 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, usemgl_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
Related examples
See the Use images to cluster point data example to learn how to dynamically set your icons with an expression.
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 aCGVector
struct set to 0 rightward and 0 upward. Set this property tonil
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 }
- Constant
-
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 tonil
to reset it to the default value.This property is only applied to the style if
iconImageName
is non-nil
, andtext
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
2
. Set this property tonil
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 tonil
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 oficon-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 }
- Constant
-
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 tonil
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 tonil
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
: Whensymbol-placement
is set topoint
, aligns icons east-west. Whensymbol-placement
is set toline
orline-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 ofsymbol-placement
.auto
: Whensymbol-placement
is set topoint
, this is equivalent toviewport
. Whensymbol-placement
is set toline
orline-center
, this is equivalent tomap
.
- 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 }
- Constant
-
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 tonil
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 tonil
to reset it to the default value.This property is only applied to the style if
iconImageName
is non-nil
, andtext
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 }
- Constant
-
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 containingNSEdgeInsetsZero
. Set this property tonil
to reset it to the default value.This property is only applied to the style if
iconImageName
is non-nil
, andtext
is non-nil
, andiconTextFit
is set to an expression that evaluates toMGLIconTextFitBoth
,MGLIconTextFitWidth
, orMGLIconTextFitHeight
. 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 (assign, readwrite, nonatomic, null_resettable) NSExpression *iconTextFitPadding;
Swift
var iconTextFitPadding: NSExpression! { get set }
- Constant
-
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 tonil
to reset it to the default value.This property is only applied to the style if
iconImageName
is non-nil
, andiconRotationAlignment
is set to an expression that evaluates tomap
, andsymbolPlacement
is set to an expression that evaluates to eitherMGLSymbolPlacementLine
orMGLSymbolPlacementLineCenter
. 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 tonil
to reset it to the default value.This property is only applied to the style if
text
is non-nil
, andtextRotationAlignment
is set to an expression that evaluates tomap
, andsymbolPlacement
is set to an expression that evaluates to eitherMGLSymbolPlacementLine
orMGLSymbolPlacementLineCenter
. 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
45
. Set this property tonil
to reset it to the default value.This property is only applied to the style if
text
is non-nil
, andsymbolPlacement
is set to an expression that evaluates to eitherMGLSymbolPlacementLine
orMGLSymbolPlacementLineCenter
. 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
10
. Set this property tonil
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 tonil
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 tonil
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 onLineString
andPolygon
geometries.line-center
: The label is placed at the center of the line of the geometry. Can only be used onLineString
andPolygon
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 (assign, readwrite, nonatomic, null_resettable) NSExpression *symbolPlacement;
Swift
var symbolPlacement: NSExpression! { get set }
- Constant
-
Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key when they overlap. Features with a lower sort key will have priority over other features when doing placement.
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 *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 tonil
to reset it to the default value.This property is only applied to the style if
symbolPlacement
is set to an expression that evaluates toline
. 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 }
-
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 tonil
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
: Ifsymbol-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 (assign, readwrite, nonatomic, null_resettable) NSExpression *symbolZOrder;
Swift
var symbolZOrder: NSExpression! { get set }
- Constant
-
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, usemgl_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
Related examples
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 (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 tonil
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 tonil
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 }
- Constant
-
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’sglyphs
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 tonil
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
16
. Set this property tonil
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 tonil
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 tonil
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 (assign, readwrite, nonatomic, null_resettable) NSExpression *textJustification;
Swift
var textJustification: NSExpression! { get set }
- Constant
-
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 tonil
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 tonil
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 aCGVector
struct set to 0 ems rightward and 0 ems upward. Set this property tonil
to reset it to the default value.This property is only applied to the style if
text
is non-nil
, andtextRadialOffset
is set tonil
. 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 }
- Constant
-
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 tonil
to reset it to the default value.This property is only applied to the style if
text
is non-nil
, andiconImageName
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
2
. Set this property tonil
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 tonil
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 oftext-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 }
- Constant
-
Radial offset of text, in the direction of the symbol’s anchor. Useful in combination with
textVariableAnchor
, which doesn’t support the two-dimensionaltextOffset
.This property is measured in ems.
The default value of this property is an expression that evaluates to the float
0
. Set this property tonil
to reset it to the default value.This property is only applied to the style if
textOffset
is set tonil
. 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 *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 tonil
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 tonil
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
: Whensymbol-placement
is set topoint
, aligns text east-west. Whensymbol-placement
is set toline
orline-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 ofsymbol-placement
.auto
: Whensymbol-placement
is set topoint
, this is equivalent toviewport
. Whensymbol-placement
is set toline
orline-center
, this is equivalent tomap
.
- 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 }
- Constant
-
Specifies how to capitalize text.
The default value of this property is an expression that evaluates to
none
. Set this property tonil
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 }
- Constant
-
To increase the chance of placing high-priority labels on the map, you can provide an array of
textAnchor
locations: the render will attempt to place the label at each location, in order, before moving onto the next label. UsetextJustify: auto
to choose justification based on anchor position. To apply an offset, use thetextRadialOffset
instead of the two-dimensionaltextOffset
.This property is only applied to the style if
textAnchor
is set tonil
, andtextOffset
is set tonil
, andsymbolPlacement
is set to an expression that evaluates to orMGLSymbolPlacementPoint
. Otherwise, it is ignored.You can set this property to an expression containing any of the following:
- Constant
MGLTextAnchor
array values - Constant array, whose 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 (assign, readwrite, nonatomic, null_resettable) NSExpression *textVariableAnchor;
Swift
var textVariableAnchor: NSExpression! { get set }
- Constant
-
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 tonil
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 (assign, readwrite, nonatomic, null_resettable) NSExpression *iconColor;
Swift
var iconColor: NSExpression! { get set }
- Constant
-
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
0
. Set this property tonil
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
NSColor.clearColor
. Set this property tonil
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 (assign, readwrite, nonatomic, null_resettable) NSExpression *iconHaloColor;
Swift
var iconHaloColor: NSExpression! { get set }
- Constant
-
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
0
. Set this property tonil
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 tonil
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 aCGVector
struct set to 0 points rightward and 0 points upward. Set this property tonil
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 }
- Constant
-
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 tonil
to reset it to the default value.This property is only applied to the style if
iconImageName
is non-nil
, andiconTranslation
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 }
- Constant
-
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 tonil
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 (assign, readwrite, nonatomic, null_resettable) NSExpression *textColor;
Swift
var textColor: NSExpression! { get set }
- Constant
-
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
0
. Set this property tonil
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
NSColor.clearColor
. Set this property tonil
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 (assign, readwrite, nonatomic, null_resettable) NSExpression *textHaloColor;
Swift
var textHaloColor: NSExpression! { get set }
- Constant
-
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
0
. Set this property tonil
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 tonil
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 aCGVector
struct set to 0 points rightward and 0 points upward. Set this property tonil
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 }
- Constant
-
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 tonil
to reset it to the default value.This property is only applied to the style if
text
is non-nil
, andtextTranslation
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 }
- Constant