MTBackgroundLayer

public class MTBackgroundLayer : MTLayer, @unchecked Sendable, Codable

The background style layer covers the entire map. Use a background style layer to configure a color or pattern to show below all other map content. If the background layer is transparent or omitted from the style, any part of the map view that does not show another style layer is transparent.

Core properties

  • Unique layer identifier.

    Declaration

    Swift

    public var identifier: String
  • Type of the layer.

    Declaration

    Swift

    public private(set) var type: MTLayerType { get }
  • Background layers have no source. This placeholder satisfies the MTLayer protocol. It is ignored during encoding/decoding and by the style bridge.

    Declaration

    Swift

    public var sourceIdentifier: String
  • The maximum zoom level for the layer. Optional number between 0 and 24. At zoom levels equal to or greater than the maxzoom, the layer will be hidden.

    Declaration

    Swift

    public var maxZoom: Double?
  • The minimum zoom level for the layer. Optional number between 0 and 24. At zoom levels less than the minzoom, the layer will be hidden.

    Declaration

    Swift

    public var minZoom: Double?
  • Background layers have no source layer; present only to satisfy MTLayer protocol.

    Declaration

    Swift

    public var sourceLayer: String?

Paint properties

  • The color with which the background will be drawn. Can be a constant color or an expression. Defaults to black.

    Declaration

    Swift

    public var color: MTStyleValue?
  • The opacity at which the background will be drawn. Optional number between 0 and 1 inclusive. Defaults to 1.

    Declaration

    Swift

    public var opacity: Double?
  • Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two.

    Declaration

    Swift

    public var pattern: String?

Layout properties

Initializers

Codable

  • Initializes layer from the decoder.

    Declaration

    Swift

    public required init(from decoder: any Decoder) throws
  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • Adds layer to map DSL style.

    Prefer MTStyle.addLayer(_:) on MTMapView instead.

    Declaration

    Swift

    public func addToMap(_ mapView: MTMapView)

Modifiers (for DSL chaining). Not for external use.

  • Undocumented

    Declaration

    Swift

    @discardableResult
    public func maxZoom(_ value: Double) -> Self
  • Undocumented

    Declaration

    Swift

    @discardableResult
    public func minZoom(_ value: Double) -> Self
  • Sets a constant background color value.

    Declaration

    Swift

    @discardableResult
    public func color(_ value: UIColor) -> Self
  • Sets a background color expression (e.g., interpolate by zoom).

    Declaration

    Swift

    @discardableResult
    public func paintColorExpression(_ expr: MTPropertyValue) -> Self
  • Sets the background opacity (0–1).

    Declaration

    Swift

    @discardableResult
    public func opacity(_ value: Double) -> Self
  • Sets the background sprite pattern name.

    Declaration

    Swift

    @discardableResult
    public func pattern(_ value: String) -> Self
  • Sets the background visibility.

    Declaration

    Swift

    @discardableResult
    public func visibility(_ value: MTLayerVisibility) -> Self