---
title: "MTRasterTileSource | Mobile sdk | Mobile sdk ios | Ios"
description: "A raster tile source."
---

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

# MTRasterTileSource

```
public class MTRasterTileSource : MTTileSource, @unchecked Sendable
```

A raster tile source.

For raster tiles hosted by MapTiler, the “url” value should be of the form [https://api.maptiler.com/tiles/\[tilesetid\]/tiles.json?key=](https://api.maptiler.com/tiles/%5Btilesetid%5D/tiles.json?key=)

-   `[identifier](#/s:11MapTilerSDK18MTRasterTileSourceC10identifierSSvp)`
    
    Unique identifier of a source.
    
    #### Declaration
    
    Swift
    
    ```
    public var identifier: String
    ```
    
-   `[bounds](#/s:11MapTilerSDK18MTRasterTileSourceC6boundsSaySdGvp)`
    
    An array containing the longitude and latitude of the southwest and northeast corners of the source’s bounding box in the following order: \[sw.lng, sw.lat, ne.lng, ne.lat\].
    
    Note
    
    Defaults to \[-180, -85.051129, 180, 85.051129\].
    
    #### Declaration
    
    Swift
    
    ```
    public var bounds: [Double]
    ```
    
-   `[maxZoom](#/s:11MapTilerSDK18MTRasterTileSourceC7maxZoomSdvp)`
    
    Maximum zoom level for which tiles are available.
    
    Note
    
    Defaults to 22.
    
    #### Declaration
    
    Swift
    
    ```
    public var maxZoom: Double
    ```
    
-   `[minZoom](#/s:11MapTilerSDK18MTRasterTileSourceC7minZoomSdvp)`
    
    Minimum zoom level for which tiles are available.
    
    Note
    
    Defaults to 0.
    
    #### Declaration
    
    Swift
    
    ```
    public var minZoom: Double
    ```
    
-   `[scheme](#/s:11MapTilerSDK18MTRasterTileSourceC6schemeAA12MTTileSchemeOvp)`
    
    Scheme used for tiles.
    
    Influences the y direction of the tile coordinates. The global-mercator (aka Spherical Mercator) profile is assumed.
    
    #### Declaration
    
    Swift
    
    ```
    public var scheme: MTTileScheme
    ```
    
-   `[tileSize](#/s:11MapTilerSDK18MTRasterTileSourceC8tileSizeSivp)`
    
    The minimum visual size to display tiles for this layer. Units in pixels.
    
    Note
    
    Defaults to 512. Only configurable for raster layers.
    
    #### Declaration
    
    Swift
    
    ```
    public var tileSize: Int
    ```
    
-   `[tiles](#/s:11MapTilerSDK18MTRasterTileSourceC5tilesSay10Foundation3URLVGSgvp)`
    
    An array of one or more tile source URLs.
    
    #### Declaration
    
    Swift
    
    ```
    public var tiles: [URL]?
    ```
    
-   `[url](#/s:11MapTilerSDK18MTRasterTileSourceC3url10Foundation3URLVSgvp)`
    
    A URL to a TileJSON resource. Supported protocols are http, https.
    
    #### Declaration
    
    Swift
    
    ```
    public var url: URL?
    ```
    
-   `[attribution](#/s:11MapTilerSDK18MTRasterTileSourceC11attributionSSSgvp)`
    
    Attribution to be displayed when the map is shown to a user.
    
    #### Declaration
    
    Swift
    
    ```
    public var attribution: String?
    ```
    
-   `[type](#/s:11MapTilerSDK18MTRasterTileSourceC4typeAA12MTSourceTypeOvp)`
    
    Type of the source.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var type: MTSourceType { get }
    ```
    
-   `[init(identifier:url:)](#/s:11MapTilerSDK18MTRasterTileSourceC10identifier3urlACSS_10Foundation3URLVtcfc)`
    
    Initializes the source with unique id and url to TileJSON resource.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String, url: URL)
    ```
    
-   `[init(identifier:tiles:)](#/s:11MapTilerSDK18MTRasterTileSourceC10identifier5tilesACSS_Say10Foundation3URLVGtcfc)`
    
    Initializes the source with unique id and one or more tile source urls.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String, tiles: [URL])
    ```
    
-   `[init(identifier:bounds:maxZoom:minZoom:scheme:tileSize:tiles:url:attribution:)](#/s:11MapTilerSDK18MTRasterTileSourceC10identifier6bounds7maxZoom03minJ06scheme8tileSize5tiles3url11attributionACSS_SaySdGS2dAA12MTTileSchemeOSiSay10Foundation3URLVGSgARSgSSSgtcfc)`
    
    Initializes the source with all options.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        identifier: String,
        bounds: [Double],
        maxZoom: Double,
        minZoom: Double,
        scheme: MTTileScheme,
        tileSize: Int = 512,
        tiles: [URL]? = nil,
        url: URL? = nil,
        attribution: String? = nil
    )
    ```
    
-   `[setURL(url:in:completionHandler:)](#/s:11MapTilerSDK18MTRasterTileSourceC6setURL3url2in17completionHandlery10Foundation0H0V_AA9MTMapViewCys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Sets the url of the source.
    
    Used for updating the source data.
    
    #### Declaration
    
    Swift
    
    ```
    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setURL(url: URL, in mapView: MTMapView, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>url</em></code></td><td><div><p>url to Raster Tile resource.</p></div></td></tr><tr><td><code><em>mapView</em></code></td><td><div><p>MTMapView which holds the source.</p></div></td></tr><tr><td><code><em>completionHandler</em></code></td><td><div><p>A handler block to execute when function finishes.</p></div></td></tr></tbody></table>
    
-   `[setTiles(tiles:in:completionHandler:)](#/s:11MapTilerSDK18MTRasterTileSourceC8setTiles5tiles2in17completionHandlerySay10Foundation3URLVG_AA9MTMapViewCys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Sets the tiles of the source.
    
    Used for updating the source data.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setTiles(
        tiles: [URL],
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>tiles</em></code></td><td><div><p>list of urls with tile resources.</p></div></td></tr><tr><td><code><em>mapView</em></code></td><td><div><p>MTMapView which holds the source.</p></div></td></tr><tr><td><code><em>completionHandler</em></code></td><td><div><p>A handler block to execute when function finishes.</p></div></td></tr></tbody></table>
    
-   `[setURL(url:in:)](#/s:11MapTilerSDK18MTRasterTileSourceC6setURL3url2iny10Foundation0H0V_AA9MTMapViewCtYaF)` Asynchronous
    
    Sets the url of the source.
    
    Used for updating the source data.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setURL(url: URL, in mapView: MTMapView) async
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>url</em></code></td><td><div><p>url to Raster Tile resource.</p></div></td></tr><tr><td><code><em>mapView</em></code></td><td><div><p>MTMapView which holds the source.</p></div></td></tr></tbody></table>
    
-   `[setTiles(tiles:in:)](#/s:11MapTilerSDK18MTRasterTileSourceC8setTiles5tiles2inySay10Foundation3URLVG_AA9MTMapViewCtYaF)` Asynchronous
    
    Sets the tiles of the source.
    
    Used for updating the source data.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setTiles(tiles: [URL], in mapView: MTMapView) async
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>tiles</em></code></td><td><div><p>list of urls with tile resources.</p></div></td></tr><tr><td><code><em>mapView</em></code></td><td><div><p>MTMapView which holds the source.</p></div></td></tr></tbody></table>
    
-   `[addToMap(_:)](#/s:11MapTilerSDK18MTRasterTileSourceC05addToA0yyAA9MTMapViewCF)`
    
    Adds source to map DSL style.
    
    Prefer `[addSource(_:)](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTStyle/#/s:11MapTilerSDK7MTStyleC9addSourceyyAA8MTSource_pYaKF)` on MTMapView instead.
    
    #### Declaration
    
    Swift
    
    ```
    public func addToMap(_ mapView: MTMapView)
    ```
