Style Layers

MGLStyleLayer


      @interface MGLStyleLayer : NSObject

MGLStyleLayer is an abstract base class for style layers. A style layer manages the layout and appearance of content at a specific z-index in a style. An MGLStyle object consists of one or more MGLStyleLayer objects.

Each style layer defined by the style JSON file is represented at runtime by an MGLStyleLayer object, which you can use to refine the map’s appearance. You can also add and remove style layers dynamically.

Create instances of MGLBackgroundStyleLayer and the concrete subclasses of MGLForegroundStyleLayer in order to use MGLStyleLayer‘s properties and methods. You do not create instances of MGLStyleLayer directly, and do not create your own subclasses of this class.

Do not add MGLStyleLayer objects to the style property of a MGLMapView before -mapView:didFinishLoadingStyle: is called.

Identifying a Style Layer

  • identifier

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

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull identifier;

    Swift

    var identifier: String { get }

Configuring a Style Layer’s Visibility

  • visible

    Whether this layer is displayed. A value of NO hides the layer.

    See the Show and hide a layer example to learn how to toggle an MGLStyleLayer object’s visibility.

    Declaration

    Objective-C

    @property (nonatomic, getter=isVisible) BOOL visible;

    Swift

    var isVisible: Bool { get set }
  • maximumZoomLevel

    The maximum zoom level at which the layer gets parsed and appears. This value is a floating-point number.

    Declaration

    Objective-C

    @property (nonatomic) float maximumZoomLevel;

    Swift

    var maximumZoomLevel: Float { get set }
  • minimumZoomLevel

    The minimum zoom level at which the layer gets parsed and appears. This value is a floating-point number.

    Declaration

    Objective-C

    @property (nonatomic) float minimumZoomLevel;

    Swift

    var minimumZoomLevel: Float { get set }

MGLForegroundStyleLayer


      @interface MGLForegroundStyleLayer : MGLStyleLayer

MGLForegroundStyleLayer is an abstract superclass for style layers whose content is defined by an MGLSource object.

Create instances of MGLRasterStyleLayer, MGLHillshadeStyleLayer, and the concrete subclasses of MGLVectorStyleLayer in order to use MGLForegroundStyleLayer‘s methods. Do not create instances of MGLForegroundStyleLayer directly, and do not create your own subclasses of this class.

Specifying a Style Layer’s Content

  • sourceIdentifier

    Identifier of the source from which the receiver obtains the data to style.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *sourceIdentifier;

    Swift

    var sourceIdentifier: String? { get }

MGLBackgroundStyleLayer


      @interface MGLBackgroundStyleLayer : MGLStyleLayer

An MGLBackgroundStyleLayer is a style layer that covers the entire map. Use a background style layer to configure a color or pattern to show below all other map content. If the style’s other layers use the Mapbox Streets source, the background style layer is responsible for drawing land, whereas the oceans and other bodies of water are drawn by MGLFillStyleLayer objects.

A background style layer is typically the bottommost layer in a style, because it covers the entire map and can occlude any layers below it. You can therefore access it by getting the last item in the MGLStyle.layers array.

If the background style layer is transparent or omitted from the style, any portion of the map view that does not show another style layer is transparent.

  • -initWithIdentifier:

    Returns a background style layer initialized with an identifier.

    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;

    Swift

    init(identifier: String)

    Parameters

    identifier

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

Accessing the Paint attribute’s

  • backgroundColor

    The color with which the background will be drawn.

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

    This property is only applied to the style if backgroundPattern is set to nil. Otherwise, it is ignored.

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *backgroundColor;

    Swift

    var backgroundColor: NSExpression! { get set }
  • backgroundColorTransition

    The transition affecting any changes to this layer’s backgroundColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition backgroundColorTransition;

    Swift

    var backgroundColorTransition: MGLTransition { get set }
  • backgroundOpacity

    The opacity at which the background 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.

    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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *backgroundOpacity;

    Swift

    var backgroundOpacity: NSExpression! { get set }
  • backgroundOpacityTransition

    The transition affecting any changes to this layer’s backgroundOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition backgroundOpacityTransition;

    Swift

    var backgroundOpacityTransition: MGLTransition { get set }
  • backgroundPattern

    Name of image in style images to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512).

    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
    • 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, null_resettable) NSExpression *backgroundPattern;

    Swift

    var backgroundPattern: NSExpression! { get set }
  • backgroundPatternTransition

    The transition affecting any changes to this layer’s backgroundPattern property.

    This property corresponds to the background-pattern-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition backgroundPatternTransition;

    Swift

    var backgroundPatternTransition: MGLTransition { get set }

MGLRasterStyleLayer


      @interface MGLRasterStyleLayer : MGLForegroundStyleLayer

An MGLRasterStyleLayer is a style layer that renders georeferenced raster imagery on the map, especially raster tiles.

Use a raster style layer to configure the color parameters of raster tiles loaded by an MGLRasterTileSource object or raster images loaded by an MGLImageSource object. For example, you could use a raster style layer to render Mapbox Satellite imagery, a raster tile set uploaded to Mapbox Studio, or a raster map authored in TileMill, the classic Mapbox Editor, or Mapbox Studio Classic.

Raster images may also be used as icons or patterns in a style layer. To register an image for use as an icon or pattern, use the -[MGLStyle setImage:forName:] method. To configure a point annotation’s image, use the MGLAnnotationImage class.

You can access an existing raster 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 raster style layer and add it to the style using a method such as -[MGLStyle addLayer:].

See the Add an image and Add raster imagery examples to learn how to add imagery with this style layer.

Example

let layer = MGLRasterStyleLayer(identifier: "clouds", source: source)
      layer.rasterOpacity = NSExpression(forConstantValue: 0.5)
      mapView.style?.addLayer(layer)
      
  • -initWithIdentifier:source:

    Returns a raster 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.

Accessing the Paint Attributes

  • maximumRasterBrightness

    Increase or reduce the brightness of the image. The value is the maximum brightness.

    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 attribute corresponds to the raster-brightness-max layout property in the Mapbox Style Specification.

    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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *maximumRasterBrightness;

    Swift

    var maximumRasterBrightness: NSExpression! { get set }
  • maximumRasterBrightnessTransition

    The transition affecting any changes to this layer’s maximumRasterBrightness property.

    This property corresponds to the raster-brightness-max-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition maximumRasterBrightnessTransition;

    Swift

    var maximumRasterBrightnessTransition: MGLTransition { get set }
  • minimumRasterBrightness

    Increase or reduce the brightness of the image. The value is the minimum brightness.

    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 attribute corresponds to the raster-brightness-min layout property in the Mapbox Style Specification.

    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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *minimumRasterBrightness;

    Swift

    var minimumRasterBrightness: NSExpression! { get set }
  • minimumRasterBrightnessTransition

    The transition affecting any changes to this layer’s minimumRasterBrightness property.

    This property corresponds to the raster-brightness-min-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition minimumRasterBrightnessTransition;

    Swift

    var minimumRasterBrightnessTransition: MGLTransition { get set }
  • rasterContrast

    Increase or reduce the contrast of the image.

    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.

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

    • Constant numeric values between −1 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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *rasterContrast;

    Swift

    var rasterContrast: NSExpression! { get set }
  • rasterContrastTransition

    The transition affecting any changes to this layer’s rasterContrast property.

    This property corresponds to the raster-contrast-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition rasterContrastTransition;

    Swift

    var rasterContrastTransition: MGLTransition { get set }
  • rasterFadeDuration

    Fade duration when a new tile is added.

    This property is measured in milliseconds.

    The default value of this property is an expression that evaluates to the float 300. 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 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, null_resettable) NSExpression *rasterFadeDuration;

    Swift

    var rasterFadeDuration: NSExpression! { get set }
  • rasterHueRotation

    Rotates hues around the color wheel.

    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 attribute corresponds to the raster-hue-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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *rasterHueRotation;

    Swift

    var rasterHueRotation: NSExpression! { get set }
  • rasterHueRotationTransition

    The transition affecting any changes to this layer’s rasterHueRotation property.

    This property corresponds to the raster-hue-rotate-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition rasterHueRotationTransition;

    Swift

    var rasterHueRotationTransition: MGLTransition { get set }
  • rasterOpacity

    The opacity at which the image 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.

    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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *rasterOpacity;

    Swift

    var rasterOpacity: NSExpression! { get set }
  • rasterOpacityTransition

    The transition affecting any changes to this layer’s rasterOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition rasterOpacityTransition;

    Swift

    var rasterOpacityTransition: MGLTransition { get set }
  • rasterResamplingMode

    The resampling/interpolation method to use for overscaling, also known as texture magnification filter

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

    This attribute corresponds to the raster-resampling layout property in the Mapbox Style Specification.

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

    • Constant MGLRasterResamplingMode values
    • Any of the following constant string values:
      • linear: (Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled
      • nearest: Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled
    • 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, null_resettable) NSExpression *rasterResamplingMode;

    Swift

    var rasterResamplingMode: NSExpression! { get set }
  • rasterSaturation

    Increase or reduce the saturation of the image.

    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.

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

    • Constant numeric values between −1 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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *rasterSaturation;

    Swift

    var rasterSaturation: NSExpression! { get set }
  • rasterSaturationTransition

    The transition affecting any changes to this layer’s rasterSaturation property.

    This property corresponds to the raster-saturation-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition rasterSaturationTransition;

    Swift

    var rasterSaturationTransition: MGLTransition { get set }

MGLVectorStyleLayer


      @interface MGLVectorStyleLayer : MGLForegroundStyleLayer

MGLVectorStyleLayer is an abstract superclass for style layers whose content is defined by an MGLShapeSource or MGLVectorTileSource object.

Create instances of MGLCircleStyleLayer, MGLFillStyleLayer, MGLFillExtrusionStyleLayer, MGLHeatmapStyleLayer, MGLLineStyleLayer, and MGLSymbolStyleLayer in order to use MGLVectorStyleLayer‘s properties and methods. Do not create instances of MGLVectorStyleLayer directly, and do not create your own subclasses of this class.

Refining a Style Layer’s Content

  • sourceLayerIdentifier

    Identifier of the layer within the source identified by the sourceIdentifier property from which the receiver obtains the data to style.

    Declaration

    Objective-C

    @property (nonatomic, nullable) NSString *sourceLayerIdentifier;

    Swift

    var sourceLayerIdentifier: String? { get set }
  • predicate

    The style layer’s predicate.

    Use the style layer’s predicate to include only the features in the source layer that satisfy a condition that you define. If the style layer initially comes from the style, its predicate corresponds to the filter property in the style JSON.

    See the “Predicates and Expressions” guide for details about the predicate syntax supported by this class.

    Example

    To filter the layer to include only the features whose index attribute is 5 or 10 and whose ele attribute is at least 1,500, you could create an NSCompoundPredicate along these lines:

    let layer = MGLLineStyleLayer(identifier: "contour", source: terrain)
          layer.sourceLayerIdentifier = "contours"
          layer.predicate = NSPredicate(format: "(index == 5 || index == 10) && CAST(ele, 'NSNumber') >= 1500.0")
          mapView.style?.addLayer(layer)
          

    Declaration

    Objective-C

    @property (nonatomic, nullable) NSPredicate *predicate;

    Swift

    var predicate: NSPredicate? { get set }

MGLCircleStyleLayer


      @interface MGLCircleStyleLayer : MGLVectorStyleLayer

An MGLCircleStyleLayer is a style layer that renders one or more filled circles on the map.

Use a circle style layer to configure the visual appearance of point or point collection features. These features can come from vector tiles loaded by an MGLVectorTileSource object, or they can be MGLPointAnnotation, MGLPointFeature, MGLPointCollection, or MGLPointCollectionFeature instances in an MGLShapeSource or MGLComputedShapeSource object.

A circle style layer renders circles whose radii are measured in screen units. To display circles on the map whose radii correspond to real-world distances, use many-sided regular polygons and configure their appearance using an MGLFillStyleLayer object.

You can access an existing circle 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 circle style layer and add it to the style using a method such as -[MGLStyle addLayer:].

See the Data-driven circles, Add multiple shapes from a single shape source, and Cluster point data examples to learn how to add circles to your map using this style layer.

Example

let layer = MGLCircleStyleLayer(identifier: "circles", source: population)
      layer.sourceLayerIdentifier = "population"
      layer.circleColor = NSExpression(forConstantValue: UIColor.green)
      
      let stops = NSExpression(forConstantValue: [12: 2,
                                                  22: 180])
      layer.circleRadius = NSExpression(forMGLInterpolating: .zoomLevelVariable,
                                        curveType: .exponential,
                                        parameters: NSExpression(forConstantValue: 1.75),
                                        stops: stops)
      
      layer.circleOpacity = NSExpression(forConstantValue: 0.7)
      layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married")
      mapView.style?.addLayer(layer)
      
  • initWithIdentifier:source:

    Returns a circle 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.

Accessing the Layout Attributes

  • circleSortKey

    Sorts features in ascending order based on this value. Features with a higher sort key will appear above 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, null_resettable) NSExpression *circleSortKey;

    Swift

    var circleSortKey: NSExpression! { get set }

Accessing the Paint Attributes

  • circleBlur

    Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.

    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.

    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, null_resettable) NSExpression *circleBlur;

    Swift

    var circleBlur: NSExpression! { get set }
  • circleBlurTransition

    The transition affecting any changes to this layer’s circleBlur property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleBlurTransition;

    Swift

    var circleBlurTransition: MGLTransition { get set }
  • circleColor

    The fill color of the circle.

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *circleColor;

    Swift

    var circleColor: NSExpression! { get set }
  • circleColorTransition

    The transition affecting any changes to this layer’s circleColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleColorTransition;

    Swift

    var circleColorTransition: MGLTransition { get set }
  • circleOpacity

    The opacity at which the circle 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.

    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, null_resettable) NSExpression *circleOpacity;

    Swift

    var circleOpacity: NSExpression! { get set }
  • circleOpacityTransition

    The transition affecting any changes to this layer’s circleOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleOpacityTransition;

    Swift

    var circleOpacityTransition: MGLTransition { get set }
  • circlePitchAlignment

    Orientation of circle when map is pitched.

    The default value of this property is an expression that evaluates to viewport. 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 MGLCirclePitchAlignment values
    • Any of the following constant string values:
      • map: The circle is aligned to the plane of the map.
      • viewport: The circle is aligned to the plane of 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, null_resettable) NSExpression *circlePitchAlignment;

    Swift

    var circlePitchAlignment: NSExpression! { get set }
  • circleRadius

    Circle radius.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float 5. 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 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, null_resettable) NSExpression *circleRadius;

    Swift

    var circleRadius: NSExpression! { get set }
  • circleRadiusTransition

    The transition affecting any changes to this layer’s circleRadius property.

    This property corresponds to the circle-radius-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleRadiusTransition;

    Swift

    var circleRadiusTransition: MGLTransition { get set }
  • circleScaleAlignment

    Controls the scaling behavior of the circle when the map is pitched.

    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 attribute corresponds to the circle-pitch-scale layout property in the Mapbox Style Specification.

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

    • Constant MGLCircleScaleAlignment values
    • Any of the following constant string values:
      • map: Circles are scaled according to their apparent distance to the camera.
      • viewport: Circles are not scaled.
    • 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, null_resettable) NSExpression *circleScaleAlignment;

    Swift

    var circleScaleAlignment: NSExpression! { get set }
  • circleStrokeColor

    The stroke color of the circle.

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *circleStrokeColor;

    Swift

    var circleStrokeColor: NSExpression! { get set }
  • circleStrokeColorTransition

    The transition affecting any changes to this layer’s circleStrokeColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleStrokeColorTransition;

    Swift

    var circleStrokeColorTransition: MGLTransition { get set }
  • circleStrokeOpacity

    The opacity of the circle’s stroke.

    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.

    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, null_resettable) NSExpression *circleStrokeOpacity;

    Swift

    var circleStrokeOpacity: NSExpression! { get set }
  • circleStrokeOpacityTransition

    The transition affecting any changes to this layer’s circleStrokeOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleStrokeOpacityTransition;

    Swift

    var circleStrokeOpacityTransition: MGLTransition { get set }
  • circleStrokeWidth

    The width of the circle’s stroke. Strokes are placed outside of the circleRadius.

    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.

    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, null_resettable) NSExpression *circleStrokeWidth;

    Swift

    var circleStrokeWidth: NSExpression! { get set }
  • circleStrokeWidthTransition

    The transition affecting any changes to this layer’s circleStrokeWidth property.

    This property corresponds to the circle-stroke-width-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleStrokeWidthTransition;

    Swift

    var circleStrokeWidthTransition: MGLTransition { get set }
  • circleTranslation

    The geometry’s offset.

    This property is measured in points.

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

    This attribute corresponds to the circle-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, null_resettable) NSExpression *circleTranslation;

    Swift

    var circleTranslation: NSExpression! { get set }
  • circleTranslationTransition

    The transition affecting any changes to this layer’s circleTranslation property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition circleTranslationTransition;

    Swift

    var circleTranslationTransition: MGLTransition { get set }
  • circleTranslationAnchor

    Controls the frame of reference for circleTranslation.

    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 circleTranslation is non-nil. Otherwise, it is ignored.

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

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

    • Constant MGLCircleTranslationAnchor values
    • Any of the following constant string values:
      • map: The circle is translated relative to the map.
      • viewport: The circle 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, null_resettable) NSExpression *circleTranslationAnchor;

    Swift

    var circleTranslationAnchor: NSExpression! { get set }

MGLFillStyleLayer


      @interface MGLFillStyleLayer : MGLVectorStyleLayer

An MGLFillStyleLayer is a style layer that renders one or more filled (and optionally stroked) polygons on the map.

Use a fill style layer to configure the visual appearance of polygon or multipolygon features. These features can come from vector tiles loaded by an MGLVectorTileSource object, or they can be MGLPolygon, MGLPolygonFeature, MGLMultiPolygon, or MGLMultiPolygonFeature instances in an MGLShapeSource or MGLComputedShapeSource object.

You can access an existing fill 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 fill style layer and add it to the style using a method such as -[MGLStyle addLayer:].

See the Select a feature within a layer example to learn how to use a TERNARY expression to modify the fillOpacity of an MGLFillStyleLayer object. See the Add a pattern to a polygon example to learn how to use an image to add pattern to the features styled by a MGLFillStyleLayer.

Example

let layer = MGLFillStyleLayer(identifier: "parks", source: parks)
      layer.sourceLayerIdentifier = "parks"
      layer.fillColor = NSExpression(forConstantValue: UIColor.green)
      layer.predicate = NSPredicate(format: "type == %@", "national-park")
      mapView.style?.addLayer(layer)
      
  • -initWithIdentifier:source:

    Returns a fill 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.

Accessing the Layout Attributes

  • fillSortKey

    Sorts features in ascending order based on this value. Features with a higher sort key will appear above 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, null_resettable) NSExpression *fillSortKey;

    Swift

    var fillSortKey: NSExpression! { get set }

Accessing the Paint Attributes

  • fillAntialiased

    Whether or not the fill should be antialiased.

    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 attribute corresponds to the fill-antialias 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,
                    getter=isFillAntialiased, null_resettable)
              NSExpression *fillAntialiased;

    Swift

    var fillAntialiased: NSExpression! { get set }
  • fillColor

    The color of the filled part of this layer.

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

    This property is only applied to the style if fillPattern is set to nil. Otherwise, it is ignored.

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *fillColor;

    Swift

    var fillColor: NSExpression! { get set }
  • fillColorTransition

    The transition affecting any changes to this layer’s fillColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillColorTransition;

    Swift

    var fillColorTransition: MGLTransition { get set }
  • fillOpacity

    The opacity of the entire fill layer. In contrast to the fillColor, this value will also affect the 1pt stroke around the fill, if the stroke is used.

    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.

    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, null_resettable) NSExpression *fillOpacity;

    Swift

    var fillOpacity: NSExpression! { get set }
  • fillOpacityTransition

    The transition affecting any changes to this layer’s fillOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillOpacityTransition;

    Swift

    var fillOpacityTransition: MGLTransition { get set }
  • fillOutlineColor

    The outline color of the fill. Matches the value of fillColor if unspecified.

    This property is only applied to the style if fillPattern is set to nil, and fillAntialiased is set to an expression that evaluates to YES. Otherwise, it is ignored.

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *fillOutlineColor;

    Swift

    var fillOutlineColor: NSExpression! { get set }
  • fillOutlineColorTransition

    The transition affecting any changes to this layer’s fillOutlineColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillOutlineColorTransition;

    Swift

    var fillOutlineColorTransition: MGLTransition { get set }
  • fillPattern

    Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *fillPattern;

    Swift

    var fillPattern: NSExpression! { get set }
  • fillPatternTransition

    The transition affecting any changes to this layer’s fillPattern property.

    This property corresponds to the fill-pattern-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillPatternTransition;

    Swift

    var fillPatternTransition: MGLTransition { get set }
  • fillTranslation

    The geometry’s offset.

    This property is measured in points.

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

    This attribute corresponds to the fill-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, null_resettable) NSExpression *fillTranslation;

    Swift

    var fillTranslation: NSExpression! { get set }
  • fillTranslationTransition

    The transition affecting any changes to this layer’s fillTranslation property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillTranslationTransition;

    Swift

    var fillTranslationTransition: MGLTransition { get set }
  • fillTranslationAnchor

    Controls the frame of reference for fillTranslation.

    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 fillTranslation is non-nil. Otherwise, it is ignored.

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

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

    • Constant MGLFillTranslationAnchor values
    • Any of the following constant string values:
      • map: The fill is translated relative to the map.
      • viewport: The fill 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, null_resettable) NSExpression *fillTranslationAnchor;

    Swift

    var fillTranslationAnchor: NSExpression! { get set }

MGLFillExtrusionStyleLayer


      @interface MGLFillExtrusionStyleLayer : MGLVectorStyleLayer

An MGLFillExtrusionStyleLayer is a style layer that renders one or more 3D extruded polygons on the map.

Use a fill-extrusion style layer to configure the visual appearance of polygon or multipolygon features. These features can come from vector tiles loaded by an MGLVectorTileSource object, or they can be MGLPolygon, MGLPolygonFeature, MGLMultiPolygon, or MGLMultiPolygonFeature instances in an MGLShapeSource or MGLComputedShapeSource object.

You can access an existing fill-extrusion 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 fill-extrusion style layer and add it to the style using a method such as -[MGLStyle addLayer:].

See the Display 3D buildings example to learn how to add and style 3D layers on a map.

Example

let layer = MGLFillExtrusionStyleLayer(identifier: "buildings", source: buildings)
      layer.sourceLayerIdentifier = "building"
      layer.fillExtrusionHeight = NSExpression(forKeyPath: "height")
      layer.fillExtrusionBase = NSExpression(forKeyPath: "min_height")
      layer.predicate = NSPredicate(format: "extrude == 'true'")
      mapView.style?.addLayer(layer)
      
  • -initWithIdentifier:source:

    Returns a fill-extrusion 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.

Accessing the Paint Attributes

  • fillExtrusionBase

    The height with which to extrude the base of this layer. Must be less than or equal to fillExtrusionHeight.

    This property is measured in meters.

    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 fillExtrusionHeight 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, null_resettable) NSExpression *fillExtrusionBase;

    Swift

    var fillExtrusionBase: NSExpression! { get set }
  • fillExtrusionBaseTransition

    The transition affecting any changes to this layer’s fillExtrusionBase property.

    This property corresponds to the fill-extrusion-base-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillExtrusionBaseTransition;

    Swift

    var fillExtrusionBaseTransition: MGLTransition { get set }
  • fillExtrusionColor

    The base color of this layer. The extrusion’s surfaces will be shaded differently based on this color in combination with the light settings. If this color is specified with an alpha component, the alpha component will be ignored; use fillExtrusionOpacity to set layer opacityco.

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

    This property is only applied to the style if fillExtrusionPattern is set to nil. Otherwise, it is ignored.

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *fillExtrusionColor;

    Swift

    var fillExtrusionColor: NSExpression! { get set }
  • fillExtrusionColorTransition

    The transition affecting any changes to this layer’s fillExtrusionColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillExtrusionColorTransition;

    Swift

    var fillExtrusionColorTransition: MGLTransition { get set }
  • fillExtrusionHasVerticalGradient

    Whether to apply a vertical gradient to the sides of a fill-extrusion layer. If true, sides will be shaded slightly darker farther 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 attribute corresponds to the fill-extrusion-vertical-gradient 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, null_resettable) NSExpression *fillExtrusionHasVerticalGradient;

    Swift

    var fillExtrusionHasVerticalGradient: NSExpression! { get set }
  • fillExtrusionHeight

    The height with which to extrude this layer.

    This property is measured in meters.

    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.

    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, null_resettable) NSExpression *fillExtrusionHeight;

    Swift

    var fillExtrusionHeight: NSExpression! { get set }
  • fillExtrusionHeightTransition

    The transition affecting any changes to this layer’s fillExtrusionHeight property.

    This property corresponds to the fill-extrusion-height-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillExtrusionHeightTransition;

    Swift

    var fillExtrusionHeightTransition: MGLTransition { get set }
  • fillExtrusionOpacity

    The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available.

    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.

    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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *fillExtrusionOpacity;

    Swift

    var fillExtrusionOpacity: NSExpression! { get set }
  • fillExtrusionOpacityTransition

    The transition affecting any changes to this layer’s fillExtrusionOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillExtrusionOpacityTransition;

    Swift

    var fillExtrusionOpacityTransition: MGLTransition { get set }
  • fillExtrusionPattern

    Name of image in style images to use for drawing image fill-extrusions. For seamless patterns, image width and height must be a factor of two (2, 4, 8, …, 512).

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *fillExtrusionPattern;

    Swift

    var fillExtrusionPattern: NSExpression! { get set }
  • fillExtrusionPatternTransition

    The transition affecting any changes to this layer’s fillExtrusionPattern property.

    This property corresponds to the fill-extrusion-pattern-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillExtrusionPatternTransition;

    Swift

    var fillExtrusionPatternTransition: MGLTransition { get set }
  • fillExtrusionTranslation

    The geometry’s offset.

    This property is measured in points.

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

    This attribute corresponds to the fill-extrusion-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, null_resettable) NSExpression *fillExtrusionTranslation;

    Swift

    var fillExtrusionTranslation: NSExpression! { get set }
  • fillExtrusionTranslationTransition

    The transition affecting any changes to this layer’s fillExtrusionTranslation property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition fillExtrusionTranslationTransition;

    Swift

    var fillExtrusionTranslationTransition: MGLTransition { get set }
  • fillExtrusionTranslationAnchor

    Controls the frame of reference for fillExtrusionTranslation.

    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 fillExtrusionTranslation is non-nil. Otherwise, it is ignored.

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

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

    • Constant MGLFillExtrusionTranslationAnchor values
    • Any of the following constant string values:
      • map: The fill extrusion is translated relative to the map.
      • viewport: The fill extrusion 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, null_resettable) NSExpression *fillExtrusionTranslationAnchor;

    Swift

    var fillExtrusionTranslationAnchor: NSExpression! { get set }

MGLHeatmapStyleLayer


      @interface MGLHeatmapStyleLayer : MGLVectorStyleLayer

An MGLHeatmapStyleLayer is a style layer that renders a heatmap.

A heatmap visualizes the spatial distribution of a large, dense set of point data, using color to avoid cluttering the map with individual points at low zoom levels. The points are weighted by an attribute you specify. Use a heatmap style layer in conjunction with point or point collection features. These features can come from vector tiles loaded by an MGLVectorTileSource object, or they can be MGLPointAnnotation, MGLPointFeature, MGLPointCollection, or MGLPointCollectionFeature instances in an MGLShapeSource or MGLComputedShapeSource object.

Consider accompanying a heatmap style layer with an MGLCircleStyleLayer or MGLSymbolStyleLayer at high zoom levels. If you are unsure whether the point data in an MGLShapeSource is dense enough to warrant a heatmap, you can alternatively cluster the source using the MGLShapeSourceOptionClustered option and render the data using an MGLCircleStyleLayer or MGLSymbolStyleLayer.

You can access an existing heatmap 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 heatmap style layer and add it to the style using a method such as -[MGLStyle addLayer:].

See the Create a heatmap layer example to learn how to add this style layer to your map.

Example

let layer = MGLHeatmapStyleLayer(identifier: "earthquake-heat", source: earthquakes)
      
      layer.heatmapWeight = NSExpression(forMGLInterpolating: .zoomLevelVariable,
                                          curveType: .linear,
                                          parameters: nil,
                                          stops: NSExpression(forConstantValue: [0: 0,
                                                                                 6: 1]))
      
      layer.heatmapIntensity = NSExpression(forMGLInterpolating: .zoomLevelVariable,
                                            curveType: .linear,
                                            parameters: nil,
                                            stops: NSExpression(forConstantValue: [0: 1,
                                                                                   9: 3]))
      
      mapView.style?.addLayer(layer)
      
  • -initWithIdentifier:source:

    Returns a heatmap 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.

Accessing the Paint Attributes

  • heatmapColor

    The color of each screen point based on its density value in a heatmap. This property is normally set to an interpolation or step expression with the $heatmapDensity value as its input.

    The default value of this property is an expression that evaluates to a rainbow color scale from blue to red. 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 UIColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $heatmapDensity variable

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *heatmapColor;

    Swift

    var heatmapColor: NSExpression! { get set }
  • heatmapIntensity

    Similar to heatmapWeight but controls the intensity of the heatmap globally. Primarily used for adjusting the heatmap based on zoom level.

    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.

    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, null_resettable) NSExpression *heatmapIntensity;

    Swift

    var heatmapIntensity: NSExpression! { get set }
  • heatmapIntensityTransition

    The transition affecting any changes to this layer’s heatmapIntensity property.

    This property corresponds to the heatmap-intensity-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition heatmapIntensityTransition;

    Swift

    var heatmapIntensityTransition: MGLTransition { get set }
  • heatmapOpacity

    The global opacity at which the heatmap layer 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.

    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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *heatmapOpacity;

    Swift

    var heatmapOpacity: NSExpression! { get set }
  • heatmapOpacityTransition

    The transition affecting any changes to this layer’s heatmapOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition heatmapOpacityTransition;

    Swift

    var heatmapOpacityTransition: MGLTransition { get set }
  • heatmapRadius

    Radius of influence of one heatmap point in points. Increasing the value makes the heatmap smoother, but less detailed.

    This property is measured in points.

    The default value of this property is an expression that evaluates to the float 30. 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 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 and/or feature attributes

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *heatmapRadius;

    Swift

    var heatmapRadius: NSExpression! { get set }
  • heatmapRadiusTransition

    The transition affecting any changes to this layer’s heatmapRadius property.

    This property corresponds to the heatmap-radius-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition heatmapRadiusTransition;

    Swift

    var heatmapRadiusTransition: MGLTransition { get set }
  • heatmapWeight

    A measure of how much an individual point contributes to the heatmap. A value of 10 would be equivalent to having 10 points of weight 1 in the same spot. Especially useful when combined with clustering.

    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.

    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, null_resettable) NSExpression *heatmapWeight;

    Swift

    var heatmapWeight: NSExpression! { get set }

MGLHillshadeStyleLayer


      @interface MGLHillshadeStyleLayer : MGLForegroundStyleLayer

An MGLHillshadeStyleLayer is a style layer that renders raster digital elevation model (DEM) tiles on the map.

Use a hillshade style layer to configure the color parameters of raster tiles loaded by an MGLRasterDEMSource object. For example, you could use a hillshade style layer to render Mapbox Terrain-RGB data.

To display posterized hillshading based on vector shapes, as with the Mapbox Terrain source, use an MGLVectorTileSource object in conjunction with several MGLFillStyleLayer objects.

You can access an existing hillshade 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 hillshade style layer and add it to the style using a method such as -[MGLStyle addLayer:].

Example

let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source)
      layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6)
      if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") {
          mapView.style?.insertLayer(layer, below: canalShadowLayer)
      }
      
  • -initWithIdentifier:source:

    Returns a hillshade 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.

Accessing the Paint Attributes

  • hillshadeAccentColor

    The shading color used to accentuate rugged terrain like sharp cliffs and gorges.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeAccentColor;

    Swift

    var hillshadeAccentColor: NSExpression! { get set }
  • hillshadeAccentColorTransition

    The transition affecting any changes to this layer’s hillshadeAccentColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeAccentColorTransition;

    Swift

    var hillshadeAccentColorTransition: MGLTransition { get set }
  • hillshadeExaggeration

    Intensity of the hillshade

    The default value of this property is an expression that evaluates to the float 0.5. 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 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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeExaggeration;

    Swift

    var hillshadeExaggeration: NSExpression! { get set }
  • hillshadeExaggerationTransition

    The transition affecting any changes to this layer’s hillshadeExaggeration property.

    This property corresponds to the hillshade-exaggeration-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeExaggerationTransition;

    Swift

    var hillshadeExaggerationTransition: MGLTransition { get set }
  • hillshadeHighlightColor

    The shading color of areas that faces towards the light source.

    The default value of this property is an expression that evaluates to UIColor.whiteColor. 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 UIColor values
    • Predefined functions, including mathematical and string operators
    • Conditional expressions
    • Variable assignments and references to assigned variables
    • Interpolation and step functions applied to the $zoomLevel variable

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeHighlightColor;

    Swift

    var hillshadeHighlightColor: NSExpression! { get set }
  • hillshadeHighlightColorTransition

    The transition affecting any changes to this layer’s hillshadeHighlightColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeHighlightColorTransition;

    Swift

    var hillshadeHighlightColorTransition: MGLTransition { get set }
  • hillshadeIlluminationAnchor

    Direction of light source when map is rotated.

    The default value of this property is an expression that evaluates to viewport. 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 MGLHillshadeIlluminationAnchor values
    • Any of the following constant string values:
      • map: The hillshade illumination is relative to the north direction.
      • viewport: The hillshade illumination is relative to the top of 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, null_resettable) NSExpression *hillshadeIlluminationAnchor;

    Swift

    var hillshadeIlluminationAnchor: NSExpression! { get set }
  • hillshadeIlluminationDirection

    The direction of the light source used to generate the hillshading with 0 as the top of the viewport if hillshadeIlluminationAnchor is set to MGLHillshadeIlluminationAnchorViewport and due north if hillshadeIlluminationAnchor is set to MGLHillshadeIlluminationAnchorMap.

    The default value of this property is an expression that evaluates to the float 335. 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 numeric values between 0 and 359 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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationDirection;

    Swift

    var hillshadeIlluminationDirection: NSExpression! { get set }
  • hillshadeShadowColor

    The shading color of areas that face away from the light source.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *hillshadeShadowColor;

    Swift

    var hillshadeShadowColor: NSExpression! { get set }
  • hillshadeShadowColorTransition

    The transition affecting any changes to this layer’s hillshadeShadowColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition hillshadeShadowColorTransition;

    Swift

    var hillshadeShadowColorTransition: MGLTransition { get set }

MGLLineStyleLayer


      @interface MGLLineStyleLayer : MGLVectorStyleLayer

An MGLLineStyleLayer is a style layer that renders one or more stroked polylines on the map.

Use a line style layer to configure the visual appearance of polyline or multipolyline features. These features can come from vector tiles loaded by an MGLVectorTileSource object, or they can be MGLPolyline, MGLPolylineFeature, MGLMultiPolyline, or MGLMultiPolylineFeature instances in an MGLShapeSource or MGLComputedShapeSource object.

You can access an existing line 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 line style layer and add it to the style using a method such as -[MGLStyle addLayer:].

See the Add multiple shapes from a single shape source example to learn how to add a line to your map using this style layer. See the Add a line style layer from GeoJSON example to learn how to add and style line data to an MGLMapView object at runtime.

Example

let layer = MGLLineStyleLayer(identifier: "trails-path", source: trails)
      layer.sourceLayerIdentifier = "trails"
      
      let stops = NSExpression(forConstantValue: [14: 2,
                                                  18: 20])
      layer.lineWidth = NSExpression(forMGLInterpolating: .zoomLevelVariable,
                                     curveType: .exponential,
                                     parameters: NSExpression(forConstantValue: 1.5),
                                     stops: stops)
      
      layer.lineColor = NSExpression(forConstantValue: UIColor.brown)
      layer.lineCap = NSExpression(forConstantValue: "round")
      layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking")
      mapView.style?.addLayer(layer)
      
  • -initWithIdentifier:source:

    Returns a line 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.

Accessing the Layout Attributes

  • lineCap

    The display of line endings.

    The default value of this property is an expression that evaluates to butt. 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 MGLLineCap values
    • Any of the following constant string values:
      • butt: A cap with a squared-off end which is drawn to the exact endpoint of the line.
      • round: A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line’s width and centered on the endpoint of the line.
      • square: A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line’s width.
    • 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, null_resettable) NSExpression *lineCap;

    Swift

    var lineCap: NSExpression! { get set }
  • lineJoin

    The display of lines when joining.

    The default value of this property is an expression that evaluates to miter. 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 MGLLineJoin values
    • Any of the following constant string values:
      • bevel: A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line’s width.
      • round: A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line’s width and centered on the endpoint of the line.
      • miter: A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
    • 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, null_resettable) NSExpression *lineJoin;

    Swift

    var lineJoin: NSExpression! { get set }
  • lineMiterLimit

    Used to automatically convert miter joins to bevel joins for sharp angles.

    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 lineJoin is set to an expression that evaluates to miter. 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, null_resettable) NSExpression *lineMiterLimit;

    Swift

    var lineMiterLimit: NSExpression! { get set }
  • lineRoundLimit

    Used to automatically convert round joins to miter joins for shallow angles.

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

    This property is only applied to the style if lineJoin is set to an expression that evaluates to round. 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, null_resettable) NSExpression *lineRoundLimit;

    Swift

    var lineRoundLimit: NSExpression! { get set }
  • lineSortKey

    Sorts features in ascending order based on this value. Features with a higher sort key will appear above 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, null_resettable) NSExpression *lineSortKey;

    Swift

    var lineSortKey: NSExpression! { get set }

Accessing the Paint Attributes

  • lineBlur

    Blur applied to the line, in points.

    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.

    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, null_resettable) NSExpression *lineBlur;

    Swift

    var lineBlur: NSExpression! { get set }
  • lineBlurTransition

    The transition affecting any changes to this layer’s lineBlur property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineBlurTransition;

    Swift

    var lineBlurTransition: MGLTransition { get set }
  • lineColor

    The color with which the line will be drawn.

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

    This property is only applied to the style if linePattern is set to nil. Otherwise, it is ignored.

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *lineColor;

    Swift

    var lineColor: NSExpression! { get set }
  • lineColorTransition

    The transition affecting any changes to this layer’s lineColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineColorTransition;

    Swift

    var lineColorTransition: MGLTransition { get set }
  • lineDashPattern

    Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to points, multiply the length by the current line width. Note that GeoJSON sources with lineMetrics: true specified won’t render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels.

    This property is measured in line widths.

    This property is only applied to the style if linePattern is set to nil. Otherwise, it is ignored.

    This attribute corresponds to the line-dasharray layout property in the Mapbox Style Specification.

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

    • Constant array values no less than 0
    • 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, null_resettable) NSExpression *lineDashPattern;

    Swift

    var lineDashPattern: NSExpression! { get set }
  • lineDashPatternTransition

    The transition affecting any changes to this layer’s lineDashPattern property.

    This property corresponds to the line-dasharray-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineDashPatternTransition;

    Swift

    var lineDashPatternTransition: MGLTransition { get set }
  • lineGapWidth

    Draws a line casing outside of a line’s actual path. Value indicates the width of the inner gap.

    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.

    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, null_resettable) NSExpression *lineGapWidth;

    Swift

    var lineGapWidth: NSExpression! { get set }
  • lineGapWidthTransition

    The transition affecting any changes to this layer’s lineGapWidth property.

    This property corresponds to the line-gap-width-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineGapWidthTransition;

    Swift

    var lineGapWidthTransition: MGLTransition { get set }
  • lineGradient

    The color gradient with which the line will be drawn. This property only has an effect on lines defined by an MGLShapeSource whose MGLShapeSourceOptionLineDistanceMetrics option is set to YES.

    This property is only applied to the style if lineDasharray is set to nil, and linePattern is set to nil, and the data source requirements are met. Otherwise, it is ignored.

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *lineGradient;

    Swift

    var lineGradient: NSExpression! { get set }
  • lineOffset

    The line’s offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.

    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.

    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, null_resettable) NSExpression *lineOffset;

    Swift

    var lineOffset: NSExpression! { get set }
  • lineOffsetTransition

    The transition affecting any changes to this layer’s lineOffset property.

    This property corresponds to the line-offset-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineOffsetTransition;

    Swift

    var lineOffsetTransition: MGLTransition { get set }
  • lineOpacity

    The opacity at which the line 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.

    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, null_resettable) NSExpression *lineOpacity;

    Swift

    var lineOpacity: NSExpression! { get set }
  • lineOpacityTransition

    The transition affecting any changes to this layer’s lineOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineOpacityTransition;

    Swift

    var lineOpacityTransition: MGLTransition { get set }
  • linePattern

    Name of image in style images to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, …, 512).

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *linePattern;

    Swift

    var linePattern: NSExpression! { get set }
  • linePatternTransition

    The transition affecting any changes to this layer’s linePattern property.

    This property corresponds to the line-pattern-transition property in the style JSON file format.

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition linePatternTransition;

    Swift

    var linePatternTransition: MGLTransition { get set }
  • lineTranslation

    The geometry’s offset.

    This property is measured in points.

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

    This attribute corresponds to the line-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, null_resettable) NSExpression *lineTranslation;

    Swift

    var lineTranslation: NSExpression! { get set }
  • lineTranslationTransition

    The transition affecting any changes to this layer’s lineTranslation property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineTranslationTransition;

    Swift

    var lineTranslationTransition: MGLTransition { get set }
  • lineTranslationAnchor

    Controls the frame of reference for lineTranslation.

    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 lineTranslation is non-nil. Otherwise, it is ignored.

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

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

    • Constant MGLLineTranslationAnchor values
    • Any of the following constant string values:
      • map: The line is translated relative to the map.
      • viewport: The line 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, null_resettable) NSExpression *lineTranslationAnchor;

    Swift

    var lineTranslationAnchor: NSExpression! { get set }
  • lineWidth

    Stroke thickness.

    This property is measured in points.

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

    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, null_resettable) NSExpression *lineWidth;

    Swift

    var lineWidth: NSExpression! { get set }
  • lineWidthTransition

    The transition affecting any changes to this layer’s lineWidth property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition lineWidthTransition;

    Swift

    var lineWidthTransition: MGLTransition { get set }

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)
      
  • -initWithIdentifier:source:

    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.

Accessing the Layout Attributes

  • iconAllowsOverlap

    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, null_resettable) NSExpression *iconAllowsOverlap;

    Swift

    var iconAllowsOverlap: NSExpression! { get set }
  • iconAnchor

    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, null_resettable) NSExpression *iconAnchor;

    Swift

    var iconAnchor: NSExpression! { get set }
  • iconIgnoresPlacement

    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, null_resettable) NSExpression *iconIgnoresPlacement;

    Swift

    var iconIgnoresPlacement: NSExpression! { get set }
  • iconImageName

    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, null_resettable) NSExpression *iconImageName;

    Swift

    var iconImageName: NSExpression! { get set }
  • iconOffset

    Offset distance of icon from its anchor.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *iconOffset;

    Swift

    var iconOffset: NSExpression! { get set }
  • iconOptional

    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 }
  • iconPadding

    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, null_resettable) NSExpression *iconPadding;

    Swift

    var iconPadding: NSExpression! { get set }
  • iconPitchAlignment

    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, null_resettable) NSExpression *iconPitchAlignment;

    Swift

    var iconPitchAlignment: NSExpression! { get set }
  • iconRotation

    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, null_resettable) NSExpression *iconRotation;

    Swift

    var iconRotation: NSExpression! { get set }
  • iconRotationAlignment

    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, null_resettable) NSExpression *iconRotationAlignment;

    Swift

    var iconRotationAlignment: NSExpression! { get set }
  • iconScale

    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, null_resettable) NSExpression *iconScale;

    Swift

    var iconScale: NSExpression! { get set }
  • iconTextFit

    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, null_resettable) NSExpression *iconTextFit;

    Swift

    var iconTextFit: NSExpression! { get set }
  • iconTextFitPadding

    Size of the additional area added to dimensions determined by iconTextFit.

    This property is measured in points.

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

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *iconTextFitPadding;

    Swift

    var iconTextFitPadding: NSExpression! { get set }
  • keepsIconUpright

    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, null_resettable) NSExpression *keepsIconUpright;

    Swift

    var keepsIconUpright: NSExpression! { get set }
  • keepsTextUpright

    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 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, null_resettable) NSExpression *keepsTextUpright;

    Swift

    var keepsTextUpright: NSExpression! { get set }
  • maximumTextAngle

    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 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, null_resettable) NSExpression *maximumTextAngle;

    Swift

    var maximumTextAngle: NSExpression! { get set }
  • maximumTextWidth

    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 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, null_resettable) NSExpression *maximumTextWidth;

    Swift

    var maximumTextWidth: NSExpression! { get set }
  • symbolAvoidsEdges

    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, null_resettable) NSExpression *symbolAvoidsEdges;

    Swift

    var symbolAvoidsEdges: NSExpression! { get set }
  • symbolPlacement

    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, null_resettable) NSExpression *symbolPlacement;

    Swift

    var symbolPlacement: NSExpression! { get set }
  • symbolSortKey

    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, null_resettable) NSExpression *symbolSortKey;

    Swift

    var symbolSortKey: NSExpression! { get set }
  • symbolSpacing

    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, null_resettable) NSExpression *symbolSpacing;

    Swift

    var symbolSpacing: NSExpression! { get set }
  • symbolZOrder

    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, null_resettable) NSExpression *symbolZOrder;

    Swift

    var symbolZOrder: NSExpression! { get set }
  • text

    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, null_resettable) NSExpression *text;

    Swift

    var text: NSExpression! { get set }
  • textAllowsOverlap

    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 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, null_resettable) NSExpression *textAllowsOverlap;

    Swift

    var textAllowsOverlap: NSExpression! { get set }
  • textAnchor

    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, null_resettable) NSExpression *textAnchor;

    Swift

    var textAnchor: NSExpression! { get set }
  • textFontNames

    An array of font face names used to display the text.

    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.

    See the “Customizing Fonts” guide for details on how this SDK chooses and renders fonts based on the value of this property.

    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 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, null_resettable) NSExpression *textFontNames;

    Swift

    var textFontNames: NSExpression! { get set }
  • textFontSize

    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 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, null_resettable) NSExpression *textFontSize;

    Swift

    var textFontSize: NSExpression! { get set }
  • textIgnoresPlacement

    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 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, null_resettable) NSExpression *textIgnoresPlacement;

    Swift

    var textIgnoresPlacement: NSExpression! { get set }
  • textJustification

    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 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, null_resettable) NSExpression *textJustification;

    Swift

    var textJustification: NSExpression! { get set }
  • textLetterSpacing

    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, null_resettable) NSExpression *textLetterSpacing;

    Swift

    var textLetterSpacing: NSExpression! { get set }
  • textLineHeight

    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, null_resettable) NSExpression *textLineHeight;

    Swift

    var textLineHeight: NSExpression! { get set }
  • textOffset

    Offset distance of text from its anchor.

    This property is measured in ems.

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

    This property is only applied to the style if text is non-nil, 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, null_resettable) NSExpression *textOffset;

    Swift

    var textOffset: NSExpression! { get set }
  • textOptional

    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 }
  • textPadding

    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, null_resettable) NSExpression *textPadding;

    Swift

    var textPadding: NSExpression! { get set }
  • textPitchAlignment

    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.
    • 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, null_resettable) NSExpression *textPitchAlignment;

    Swift

    var textPitchAlignment: NSExpression! { get set }
  • textRadialOffset

    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, null_resettable) NSExpression *textRadialOffset;

    Swift

    var textRadialOffset: NSExpression! { get set }
  • textRotation

    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 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, null_resettable) NSExpression *textRotation;

    Swift

    var textRotation: NSExpression! { get set }
  • textRotationAlignment

    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, null_resettable) NSExpression *textRotationAlignment;

    Swift

    var textRotationAlignment: NSExpression! { get set }
  • textTransform

    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, null_resettable) NSExpression *textTransform;

    Swift

    var textTransform: NSExpression! { get set }
  • textVariableAnchor

    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, null_resettable) NSExpression *textVariableAnchor;

    Swift

    var textVariableAnchor: NSExpression! { get set }
  • textWritingModes

    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 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, null_resettable) NSExpression *textWritingModes;

    Swift

    var textWritingModes: NSExpression! { get set }

Accessing the Paint Attributes

  • iconColor

    The tint color to apply to the icon. The iconImageName property must be set to a template image.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *iconColor;

    Swift

    var iconColor: NSExpression! { get set }
  • iconColorTransition

    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) MGLTransition iconColorTransition;

    Swift

    var iconColorTransition: MGLTransition { get set }
  • iconHaloBlur

    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, null_resettable) NSExpression *iconHaloBlur;

    Swift

    var iconHaloBlur: NSExpression! { get set }
  • iconHaloBlurTransition

    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) MGLTransition iconHaloBlurTransition;

    Swift

    var iconHaloBlurTransition: MGLTransition { get set }
  • iconHaloColor

    The color of the icon’s halo. The iconImageName property must be set to a template image.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *iconHaloColor;

    Swift

    var iconHaloColor: NSExpression! { get set }
  • iconHaloColorTransition

    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) MGLTransition iconHaloColorTransition;

    Swift

    var iconHaloColorTransition: MGLTransition { get set }
  • iconHaloWidth

    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, null_resettable) NSExpression *iconHaloWidth;

    Swift

    var iconHaloWidth: NSExpression! { get set }
  • iconHaloWidthTransition

    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) MGLTransition iconHaloWidthTransition;

    Swift

    var iconHaloWidthTransition: MGLTransition { get set }
  • iconOpacity

    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, null_resettable) NSExpression *iconOpacity;

    Swift

    var iconOpacity: NSExpression! { get set }
  • iconOpacityTransition

    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) MGLTransition iconOpacityTransition;

    Swift

    var iconOpacityTransition: MGLTransition { get set }
  • iconTranslation

    Distance that the icon’s anchor is moved from its original placement.

    This property is measured in points.

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

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

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *iconTranslation;

    Swift

    var iconTranslation: NSExpression! { get set }
  • iconTranslationTransition

    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) MGLTransition iconTranslationTransition;

    Swift

    var iconTranslationTransition: MGLTransition { get set }
  • iconTranslationAnchor

    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, null_resettable) NSExpression *iconTranslationAnchor;

    Swift

    var iconTranslationAnchor: NSExpression! { get set }
  • textColor

    The color with which the text will be drawn.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *textColor;

    Swift

    var textColor: NSExpression! { get set }
  • textColorTransition

    The transition affecting any changes to this layer’s textColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition textColorTransition;

    Swift

    var textColorTransition: MGLTransition { get set }
  • textHaloBlur

    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, null_resettable) NSExpression *textHaloBlur;

    Swift

    var textHaloBlur: NSExpression! { get set }
  • textHaloBlurTransition

    The transition affecting any changes to this layer’s textHaloBlur property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition textHaloBlurTransition;

    Swift

    var textHaloBlurTransition: MGLTransition { get set }
  • textHaloColor

    The color of the text’s halo, which helps it stand out from backgrounds.

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

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

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

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

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) NSExpression *textHaloColor;

    Swift

    var textHaloColor: NSExpression! { get set }
  • textHaloColorTransition

    The transition affecting any changes to this layer’s textHaloColor property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition textHaloColorTransition;

    Swift

    var textHaloColorTransition: MGLTransition { get set }
  • textHaloWidth

    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, null_resettable) NSExpression *textHaloWidth;

    Swift

    var textHaloWidth: NSExpression! { get set }
  • textHaloWidthTransition

    The transition affecting any changes to this layer’s textHaloWidth property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition textHaloWidthTransition;

    Swift

    var textHaloWidthTransition: MGLTransition { get set }
  • textOpacity

    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, null_resettable) NSExpression *textOpacity;

    Swift

    var textOpacity: NSExpression! { get set }
  • textOpacityTransition

    The transition affecting any changes to this layer’s textOpacity property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition textOpacityTransition;

    Swift

    var textOpacityTransition: MGLTransition { get set }
  • textTranslation

    Distance that the text’s anchor is moved from its original placement.

    This property is measured in points.

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

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

    This attribute corresponds to the text 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, null_resettable) NSExpression *textTranslation;

    Swift

    var textTranslation: NSExpression! { get set }
  • textTranslationTransition

    The transition affecting any changes to this layer’s textTranslation property.

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

    Declaration

    Objective-C

    @property (nonatomic) MGLTransition textTranslationTransition;

    Swift

    var textTranslationTransition: MGLTransition { get set }
  • textTranslationAnchor

    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 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, null_resettable) NSExpression *textTranslationAnchor;

    Swift

    var textTranslationAnchor: NSExpression! { get set }