---
title: "MTLineLayer | Mobile sdk | Mobile sdk ios | Ios"
description: "The line style layer that renders one or more stroked polylines on the map."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTLineLayer

```
public class MTLineLayer : MTLayer, @unchecked Sendable, Codable
```

The line style layer that renders one or more stroked polylines on the map.

-   `[identifier](#/s:11MapTilerSDK11MTLineLayerC10identifierSSvp)`
    
    Unique layer identifier.
    
    #### Declaration
    
    Swift
    
    ```
    public var identifier: String
    ```
    
-   `[type](#/s:11MapTilerSDK11MTLineLayerC4typeAA11MTLayerTypeOvp)`
    
    Type of the layer.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var type: MTLayerType { get }
    ```
    
-   `[sourceIdentifier](#/s:11MapTilerSDK11MTLineLayerC16sourceIdentifierSSvp)`
    
    Identifier of the source to be used for this layer.
    
    #### Declaration
    
    Swift
    
    ```
    public var sourceIdentifier: String
    ```
    
-   `[maxZoom](#/s:11MapTilerSDK11MTLineLayerC7maxZoomSdSgvp)`
    
    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?
    ```
    
-   `[minZoom](#/s:11MapTilerSDK11MTLineLayerC7minZoomSdSgvp)`
    
    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?
    ```
    
-   `[sourceLayer](#/s:11MapTilerSDK11MTLineLayerC06sourceE0SSSgvp)`
    
    Layer to use from a vector tile source.
    
    Required for vector tile sources; prohibited for all other source types, including GeoJSON sources.
    
    #### Declaration
    
    Swift
    
    ```
    public var sourceLayer: String?
    ```
    
-   `[blur](#/s:11MapTilerSDK11MTLineLayerC4blurSdSgvp)`
    
    Blur of the line.
    
    #### Declaration
    
    Swift
    
    ```
    public var blur: Double?
    ```
    
-   `[cap](#/s:11MapTilerSDK11MTLineLayerC3capAA0D3CapOSgvp)`
    
    The display of line endings.
    
    #### Declaration
    
    Swift
    
    ```
    public var cap: MTLineCap?
    ```
    
-   `[color](#/s:11MapTilerSDK11MTLineLayerC5colorSo7UIColorCSgvp)`
    
    The color with which the line will be drawn.
    
    #### Declaration
    
    Swift
    
    ```
    public var color: UIColor?
    ```
    
-   `[dashArray](#/s:11MapTilerSDK11MTLineLayerC9dashArraySaySdGSgvp)`
    
    The lengths of the alternating dashes and gaps that form the dash pattern.
    
    #### Declaration
    
    Swift
    
    ```
    public var dashArray: [Double]?
    ```
    
-   `[gapWidth](#/s:11MapTilerSDK11MTLineLayerC8gapWidthSdSgvp)`
    
    Line casing outside of a line’s actual path.
    
    #### Declaration
    
    Swift
    
    ```
    public var gapWidth: Double?
    ```
    
-   `[gradient](#/s:11MapTilerSDK11MTLineLayerC8gradientSo7UIColorCSgvp)`
    
    The gradient with which to color a line feature.
    
    Can only be used with GeoJSON sources that specify “lineMetrics”: true.
    
    #### Declaration
    
    Swift
    
    ```
    public var gradient: UIColor?
    ```
    
-   `[join](#/s:11MapTilerSDK11MTLineLayerC4joinAA0D4JoinOSgvp)`
    
    The display of lines when joining.
    
    #### Declaration
    
    Swift
    
    ```
    public var join: MTLineJoin?
    ```
    
-   `[miterLimit](#/s:11MapTilerSDK11MTLineLayerC10miterLimitSdSgvp)`
    
    Used to automatically convert miter joins to bevel joins for sharp angles.
    
    Requires join to be “miter”.
    
    #### Declaration
    
    Swift
    
    ```
    public var miterLimit: Double?
    ```
    
-   `[offset](#/s:11MapTilerSDK11MTLineLayerC6offsetSdSgvp)`
    
    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.
    
    #### Declaration
    
    Swift
    
    ```
    public var offset: Double?
    ```
    
-   `[opacity](#/s:11MapTilerSDK11MTLineLayerC7opacitySdSgvp)`
    
    Optional number between 0 and 1 inclusive.
    
    #### Declaration
    
    Swift
    
    ```
    public var opacity: Double?
    ```
    
-   `[roundLimit](#/s:11MapTilerSDK11MTLineLayerC10roundLimitSdSgvp)`
    
    Used to automatically convert round joins to miter joins for shallow angles.
    
    #### Declaration
    
    Swift
    
    ```
    public var roundLimit: Double?
    ```
    
-   `[sortKey](#/s:11MapTilerSDK11MTLineLayerC7sortKeySdSgvp)`
    
    Feature ordering value.
    
    Features with a higher sort key will appear above features with a lower sort key.
    
    #### Declaration
    
    Swift
    
    ```
    public var sortKey: Double?
    ```
    
-   `[translate](#/s:11MapTilerSDK11MTLineLayerC9translateSaySdGSgvp)`
    
    The geometry’s offset.
    
    Values are \[x, y\] where negatives indicate left and up, respectively.
    
    #### Declaration
    
    Swift
    
    ```
    public var translate: [Double]?
    ```
    
-   `[translateAnchor](#/s:11MapTilerSDK11MTLineLayerC15translateAnchorAA0d9TranslateG0OSgvp)`
    
    Controls the frame of reference for translate.
    
    #### Declaration
    
    Swift
    
    ```
    public var translateAnchor: MTLineTranslateAnchor?
    ```
    
-   `[width](#/s:11MapTilerSDK11MTLineLayerC5widthSdSgvp)`
    
    Width of the line.
    
    #### Declaration
    
    Swift
    
    ```
    public var width: Double?
    ```
    
-   `[visibility](#/s:11MapTilerSDK11MTLineLayerC10visibilityAA17MTLayerVisibilityOSgvp)`
    
    Enum controlling whether this layer is displayed.
    
    #### Declaration
    
    Swift
    
    ```
    public var visibility: MTLayerVisibility?
    ```
    
-   `[initialFilter](#/s:11MapTilerSDK11MTLineLayerC13initialFilterAA15MTPropertyValueOSgvp)`
    
    Optional initial filter to apply after the layer is added to the map.
    
    #### Declaration
    
    Swift
    
    ```
    public var initialFilter: MTPropertyValue?
    ```
    
-   `[init(identifier:sourceIdentifier:maxZoom:minZoom:sourceLayer:)](#/s:11MapTilerSDK11MTLineLayerC10identifier16sourceIdentifier7maxZoom03minJ00gE0ACSS_SSS2dSSSgtcfc)`
    
    Initializes the layer with unique identifier, source identifier, max and min zoom levels and source layer, which is required for vector tile sources.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        identifier: String,
        sourceIdentifier: String,
        maxZoom: Double,
        minZoom: Double,
        sourceLayer: String? = nil
    )
    ```
    
-   `[init(identifier:sourceIdentifier:maxZoom:minZoom:sourceLayer:blur:cap:color:dashArray:gapWidth:gradient:join:miterLimit:offset:opacity:roundLimit:sortKey:translate:translateAnchor:width:visibility:)](#/s:11MapTilerSDK11MTLineLayerC10identifier16sourceIdentifier7maxZoom03minJ00gE04blur3cap5color9dashArray8gapWidth8gradient4join10miterLimit6offset7opacity05roundV07sortKey9translate15translateAnchor5width10visibilityACSS_SSSdSgAYSSSgAyA0D3CapOSgSo7UIColorCSgSaySdGSgAYA4_AA0D4JoinOSgA5YA6_AA0D15TranslateAnchorOSgAyA17MTLayerVisibilityOSgtcfc)`
    
    Initializes the layer with all options.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        identifier: String,
        sourceIdentifier: String,
        maxZoom: Double? = nil,
        minZoom: Double? = nil,
        sourceLayer: String? = nil,
        blur: Double? = 0.0,
        cap: MTLineCap? = .butt,
        color: UIColor? = .black,
        dashArray: [Double]? = nil,
        gapWidth: Double? = 0.0,
        gradient: UIColor? = nil,
        join: MTLineJoin? = .miter,
        miterLimit: Double? = 2.0,
        offset: Double? = 0.0,
        opacity: Double? = 1.0,
        roundLimit: Double? = 1.05,
        sortKey: Double? = nil,
        translate: [Double]? = [0.0, 0.0],
        translateAnchor: MTLineTranslateAnchor? = .map,
        width: Double? = 1.0,
        visibility: MTLayerVisibility? = .visible
    )
    ```
    
-   `[init(from:)](#/s:11MapTilerSDK11MTLineLayerC4fromACs7Decoder_p_tKcfc)`
    
    Initializes layer from the decoder.
    
    #### Declaration
    
    Swift
    
    ```
    public required init(from decoder: any Decoder) throws
    ```
    
-   `[encode(to:)](#/s:SE6encode2toys7Encoder_p_tKF)`
    
    #### Declaration
    
    Swift
    
    ```
    public func encode(to encoder: Encoder) throws
    ```
    
-   `[addToMap(_:)](#/s:11MapTilerSDK11MTLineLayerC05addToA0yyAA9MTMapViewCF)`
    
    Adds layer to map DSL style.
    
    Prefer `[addLayer(_:)](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTStyle/#/s:11MapTilerSDK7MTStyleC8addLayeryyAA7MTLayer_pYaKF)` on MTMapView instead.
    
    #### Declaration
    
    Swift
    
    ```
    public func addToMap(_ mapView: MTMapView)
    ```
    
-   `[maxZoom(_:)](#/s:11MapTilerSDK11MTLineLayerC7maxZoomyACXDSdF)`
    
    Modifier. Sets the `[maxZoom](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC7maxZoomSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func maxZoom(_ value: Double) -> Self
    ```
    
-   `[minZoom(_:)](#/s:11MapTilerSDK11MTLineLayerC7minZoomyACXDSdF)`
    
    Modifier. Sets the `[minZoom](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC7minZoomSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func minZoom(_ value: Double) -> Self
    ```
    
-   `[sourceLayer(_:)](#/s:11MapTilerSDK11MTLineLayerC06sourceE0yACXDSSF)`
    
    Modifier. Sets the `[sourceLayer](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC06sourceE0SSSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func sourceLayer(_ value: String) -> Self
    ```
    
-   `[blur(_:)](#/s:11MapTilerSDK11MTLineLayerC4bluryACXDSdF)`
    
    Modifier. Sets the `[blur](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC4blurSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func blur(_ value: Double) -> Self
    ```
    
-   `[cap(_:)](#/s:11MapTilerSDK11MTLineLayerC3capyACXDAA0D3CapOF)`
    
    Modifier. Sets the `[cap](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC3capAA0D3CapOSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func cap(_ value: MTLineCap) -> Self
    ```
    
-   `[color(_:)](#/s:11MapTilerSDK11MTLineLayerC5coloryACXDSo7UIColorCF)`
    
    Modifier. Sets the `[color](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC5colorSo7UIColorCSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func color(_ value: UIColor) -> Self
    ```
    
-   `[dashArray(_:)](#/s:11MapTilerSDK11MTLineLayerC9dashArrayyACXDSaySdGF)`
    
    Modifier. Sets the `[dashArray](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC9dashArraySaySdGSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func dashArray(_ value: [Double]) -> Self
    ```
    
-   `[gapWidth(_:)](#/s:11MapTilerSDK11MTLineLayerC8gapWidthyACXDSdF)`
    
    Modifier. Sets the `[gapWidth](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC8gapWidthSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func gapWidth(_ value: Double) -> Self
    ```
    
-   `[gradient(_:)](#/s:11MapTilerSDK11MTLineLayerC8gradientyACXDSo7UIColorCF)`
    
    Modifier. Sets the `[gradient](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC8gradientSo7UIColorCSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func gradient(_ value: UIColor) -> Self
    ```
    
-   `[join(_:)](#/s:11MapTilerSDK11MTLineLayerC4joinyACXDAA0D4JoinOF)`
    
    Modifier. Sets the `[join](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC4joinAA0D4JoinOSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func join(_ value: MTLineJoin) -> Self
    ```
    
-   `[miterLimit(_:)](#/s:11MapTilerSDK11MTLineLayerC10miterLimityACXDSdF)`
    
    Modifier. Sets the `[miterLimit](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC10miterLimitSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func miterLimit(_ value: Double) -> Self
    ```
    
-   `[offset(_:)](#/s:11MapTilerSDK11MTLineLayerC6offsetyACXDSdF)`
    
    Modifier. Sets the `[offset](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC6offsetSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func offset(_ value: Double) -> Self
    ```
    
-   `[opacity(_:)](#/s:11MapTilerSDK11MTLineLayerC7opacityyACXDSdF)`
    
    Modifier. Sets the `[opacity](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC7opacitySdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func opacity(_ value: Double) -> Self
    ```
    
-   `[roundLimit(_:)](#/s:11MapTilerSDK11MTLineLayerC10roundLimityACXDSdF)`
    
    Modifier. Sets the `[roundLimit](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC10roundLimitSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func roundLimit(_ value: Double) -> Self
    ```
    
-   `[sortKey(_:)](#/s:11MapTilerSDK11MTLineLayerC7sortKeyyACXDSdF)`
    
    Modifier. Sets the `[sortKey](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC7sortKeySdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func sortKey(_ value: Double) -> Self
    ```
    
-   `[translate(_:)](#/s:11MapTilerSDK11MTLineLayerC9translateyACXDSaySdGF)`
    
    Modifier. Sets the `[translate](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC9translateSaySdGSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func translate(_ value: [Double]) -> Self
    ```
    
-   `[translateAnchor(_:)](#/s:11MapTilerSDK11MTLineLayerC15translateAnchoryACXDAA0d9TranslateG0OF)`
    
    Modifier. Sets the `[translateAnchor](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC15translateAnchorAA0d9TranslateG0OSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func translateAnchor(_ value: MTLineTranslateAnchor) -> Self
    ```
    
-   `[width(_:)](#/s:11MapTilerSDK11MTLineLayerC5widthyACXDSdF)`
    
    Modifier. Sets the `[width](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC5widthSdSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func width(_ value: Double) -> Self
    ```
    
-   `[visibility(_:)](#/s:11MapTilerSDK11MTLineLayerC10visibilityyACXDAA17MTLayerVisibilityOF)`
    
    Modifier. Sets the `[visibility](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTLineLayer/#/s:11MapTilerSDK11MTLineLayerC10visibilityAA17MTLayerVisibilityOSgvp)`.
    
    Note
    
    Not to be used outside of DSL.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func visibility(_ value: MTLayerVisibility) -> Self
    ```
