---
title: "MTHeatmapLayer | Mobile sdk | Mobile sdk ios | Ios"
description: "A heatmap style layer renders a range of colors to represent the density of points in an area."
---

> 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.

# MTHeatmapLayer

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

```
extension MTHeatmapLayer: Equatable
```

A heatmap style layer renders a range of colors to represent the density of points in an area.

[](#/Core%20properties)

### Core properties

-   `[identifier](#/s:11MapTilerSDK14MTHeatmapLayerC10identifierSSvp)`
    
    Unique layer identifier.
    
    #### Declaration
    
    Swift
    
    ```
    public var identifier: String
    ```
    
-   `[type](#/s:11MapTilerSDK14MTHeatmapLayerC4typeAA11MTLayerTypeOvp)`
    
    Type of the layer.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var type: MTLayerType { get }
    ```
    
-   `[sourceIdentifier](#/s:11MapTilerSDK14MTHeatmapLayerC16sourceIdentifierSSvp)`
    
    Identifier of the source to be used for this layer.
    
    #### Declaration
    
    Swift
    
    ```
    public var sourceIdentifier: String
    ```
    
-   `[maxZoom](#/s:11MapTilerSDK14MTHeatmapLayerC7maxZoomSdSgvp)`
    
    The maximum zoom level for the layer. Optional number between 0 and 24.
    
    #### Declaration
    
    Swift
    
    ```
    public var maxZoom: Double?
    ```
    
-   `[minZoom](#/s:11MapTilerSDK14MTHeatmapLayerC7minZoomSdSgvp)`
    
    The minimum zoom level for the layer. Optional number between 0 and 24.
    
    #### Declaration
    
    Swift
    
    ```
    public var minZoom: Double?
    ```
    
-   `[sourceLayer](#/s:11MapTilerSDK14MTHeatmapLayerC06sourceE0SSSgvp)`
    
    Layer to use from a vector tile source. Required for vector tile sources; prohibited for others.
    
    #### Declaration
    
    Swift
    
    ```
    public var sourceLayer: String?
    ```
    

[](#/Paint%20properties)

### Paint properties

-   `[color](#/s:11MapTilerSDK14MTHeatmapLayerC5colorAA12MTStyleValueOSgvp)`
    
    Defines the color of each pixel based on its density value in a heatmap. Should generally be an expression using \[“heatmap-density”\].
    
    #### Declaration
    
    Swift
    
    ```
    public var color: MTStyleValue?
    ```
    
-   `[intensity](#/s:11MapTilerSDK14MTHeatmapLayerC9intensityAA12MTStyleValueOSgvp)`
    
    Similar to heatmap-weight but controls the intensity of the heatmap globally.
    
    #### Declaration
    
    Swift
    
    ```
    public var intensity: MTStyleValue?
    ```
    
-   `[opacity](#/s:11MapTilerSDK14MTHeatmapLayerC7opacityAA12MTStyleValueOSgvp)`
    
    The global opacity at which the heatmap layer will be drawn.
    
    #### Declaration
    
    Swift
    
    ```
    public var opacity: MTStyleValue?
    ```
    
-   `[radius](#/s:11MapTilerSDK14MTHeatmapLayerC6radiusAA12MTStyleValueOSgvp)`
    
    Radius of influence of one heatmap point in pixels.
    
    #### Declaration
    
    Swift
    
    ```
    public var radius: MTStyleValue?
    ```
    
-   `[weight](#/s:11MapTilerSDK14MTHeatmapLayerC6weightAA12MTStyleValueOSgvp)`
    
    A measure of how much an individual point contributes to the heatmap.
    
    #### Declaration
    
    Swift
    
    ```
    public var weight: MTStyleValue?
    ```
    

[](#/Layout%20properties)

### Layout properties

-   `[visibility](#/s:11MapTilerSDK14MTHeatmapLayerC10visibilityAA17MTLayerVisibilityOSgvp)`
    
    Whether this layer is displayed. Defaults to “visible”.
    
    #### Declaration
    
    Swift
    
    ```
    public var visibility: MTLayerVisibility?
    ```
    

[](#/Optional%20filter%20hooks)

### Optional filter hooks

-   `[filterExpression](#/s:11MapTilerSDK14MTHeatmapLayerC16filterExpressionAA15MTPropertyValueOSgvp)`
    
    Inline filter expression to be embedded in the layer JSON.
    
    #### Declaration
    
    Swift
    
    ```
    public var filterExpression: MTPropertyValue?
    ```
    
-   `[initialFilter](#/s:11MapTilerSDK14MTHeatmapLayerC13initialFilterAA15MTPropertyValueOSgvp)`
    
    Optional filter to apply after the layer is added to the map.
    
    #### Declaration
    
    Swift
    
    ```
    public var initialFilter: MTPropertyValue?
    ```
    

[](#/Initializers)

### Initializers

-   `[init(identifier:sourceIdentifier:)](#/s:11MapTilerSDK14MTHeatmapLayerC10identifier16sourceIdentifierACSS_SStcfc)`
    
    Initializes the layer with a unique identifier and source identifier.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String, sourceIdentifier: String)
    ```
    
-   `[init(identifier:sourceIdentifier:maxZoom:minZoom:sourceLayer:color:intensity:opacity:radius:weight:visibility:)](#/s:11MapTilerSDK14MTHeatmapLayerC10identifier16sourceIdentifier7maxZoom03minJ00gE05color9intensity7opacity6radius6weight10visibilityACSS_SSSdSgAOSSSgAA12MTStyleValueOSgA4sA17MTLayerVisibilityOSgtcfc)`
    
    Initializes the layer with all options.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        identifier: String,
        sourceIdentifier: String,
        maxZoom: Double? = nil,
        minZoom: Double? = nil,
        sourceLayer: String? = nil,
        color: MTStyleValue? = nil,
        intensity: MTStyleValue? = .number(1.0),
        opacity: MTStyleValue? = .number(1.0),
        radius: MTStyleValue? = .number(30.0),
        weight: MTStyleValue? = .number(1.0),
        visibility: MTLayerVisibility? = .visible
    )
    ```
    

[](#/Codable)

### Codable

-   `[init(from:)](#/s:Se4fromxs7Decoder_p_tKcfc)`
    
    #### 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:11MapTilerSDK14MTHeatmapLayerC05addToA0yyAA9MTMapViewCF)`
    
    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)
    ```
    
-   `[==(_:_:)](#/s:SQ2eeoiySbx_xtFZ)`
    
    #### Declaration
    
    Swift
    
    ```
    public static func == (lhs: MTHeatmapLayer, rhs: MTHeatmapLayer) -> Bool
    ```
