---
title: "MTImageSource | Mobile sdk | Mobile sdk ios | Ios"
description: "An image 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.

# MTImageSource

```
public class MTImageSource : MTSource, @unchecked Sendable
```

An image source.

The `url` value contains the image location. The `coordinates` array contains \[longitude, latitude\] pairs for the image corners listed in clockwise order: top left, top right, bottom right, bottom left.

-   `[identifier](#/s:11MapTilerSDK13MTImageSourceC10identifierSSvp)`
    
    Unique id of the source.
    
    #### Declaration
    
    Swift
    
    ```
    public var identifier: String
    ```
    
-   `[url](#/s:11MapTilerSDK13MTImageSourceC3url10Foundation3URLVSgvp)`
    
    URL that points to an image.
    
    #### Declaration
    
    Swift
    
    ```
    public var url: URL?
    ```
    
-   `[coordinates](#/s:11MapTilerSDK13MTImageSourceC11coordinatesSaySo22CLLocationCoordinate2DVGvp)`
    
    Corners of image specified as `CLLocationCoordinate2D`. Clockwise order: top-left, top-right, bottom-right, bottom-left.
    
    #### Declaration
    
    Swift
    
    ```
    public var coordinates: [CLLocationCoordinate2D]
    ```
    
-   `[type](#/s:11MapTilerSDK13MTImageSourceC4typeAA12MTSourceTypeOvp)`
    
    Type of the source.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var type: MTSourceType { get }
    ```
    
-   `[init(identifier:url:coordinates:)](#/s:11MapTilerSDK13MTImageSourceC10identifier3url11coordinatesACSS_10Foundation3URLVSaySo22CLLocationCoordinate2DVGtcfc)`
    
    Initializes the image source with required values.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String, url: URL, coordinates: [CLLocationCoordinate2D])
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>identifier</em></code></td><td><div><p>Unique id of the source.</p></div></td></tr><tr><td><code><em>url</em></code></td><td><div><p>URL to the image resource.</p></div></td></tr><tr><td><code><em>coordinates</em></code></td><td><div><p>Corners of image in clockwise order using <code>CLLocationCoordinate2D</code>.</p></div></td></tr></tbody></table>
    

[](#/Operations)

### Operations

-   `[setCoordinates(_:in:completionHandler:)](#/s:11MapTilerSDK13MTImageSourceC14setCoordinates_2in17completionHandlerySaySo22CLLocationCoordinate2DVG_AA9MTMapViewCys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Updates the coordinates of the image source.
    
    #### Declaration
    
    Swift
    
    ```
    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setCoordinates(
        _ coordinates: [CLLocationCoordinate2D],
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>coordinates</em></code></td><td><div><p>New corners of the image using <code>CLLocationCoordinate2D</code>.</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>
    
-   `[updateImage(url:coordinates:in:completionHandler:)](#/s:11MapTilerSDK13MTImageSourceC11updateImage3url11coordinates2in17completionHandlery10Foundation3URLV_SaySo22CLLocationCoordinate2DVGAA9MTMapViewCys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Updates the image URL and coordinates simultaneously.
    
    #### Declaration
    
    Swift
    
    ```
    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func updateImage(
        url: URL,
        coordinates: [CLLocationCoordinate2D],
        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>New image URL.</p></div></td></tr><tr><td><code><em>coordinates</em></code></td><td><div><p>New corners of the image using <code>CLLocationCoordinate2D</code>.</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>
    

[](#/Concurrency)

### Concurrency

-   `[setCoordinates(_:in:)](#/s:11MapTilerSDK13MTImageSourceC14setCoordinates_2inySaySo22CLLocationCoordinate2DVG_AA9MTMapViewCtYaF)` Asynchronous
    
    Updates the coordinates of the image source.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setCoordinates(_ coordinates: [CLLocationCoordinate2D], in mapView: MTMapView) async
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>coordinates</em></code></td><td><div><p>New corners of the image using <code>CLLocationCoordinate2D</code>.</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>
    
-   `[updateImage(url:coordinates:in:)](#/s:11MapTilerSDK13MTImageSourceC11updateImage3url11coordinates2iny10Foundation3URLV_SaySo22CLLocationCoordinate2DVGAA9MTMapViewCtYaF)` Asynchronous
    
    Updates the image URL and coordinates simultaneously.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func updateImage(url: URL, coordinates: [CLLocationCoordinate2D], in mapView: MTMapView) async
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>url</em></code></td><td><div><p>New image URL.</p></div></td></tr><tr><td><code><em>coordinates</em></code></td><td><div><p>New corners of the image using <code>CLLocationCoordinate2D</code>.</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>
    

[](#/DSL)

### DSL

-   `[addToMap(_:)](#/s:11MapTilerSDK13MTImageSourceC05addToA0yyAA9MTMapViewCF)`
    
    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)
    ```
