---
title: "MTCustomAnnotationView | Mobile sdk | Mobile sdk ios | Ios"
description: "Subclassable view for adding custom annotations to 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.

# MTCustomAnnotationView

```
@MainActor
open class MTCustomAnnotationView : UIView, @preconcurrency MTAnnotation
```

```
extension MTCustomAnnotationView: @preconcurrency MTMapViewContent
```

Subclassable view for adding custom annotations to the map.

-   `[identifier](#/s:11MapTilerSDK22MTCustomAnnotationViewC10identifierSSvp)`
    
    Unique id of the view.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public private(set) var identifier: String { get }
    ```
    
-   `[coordinates](#/s:11MapTilerSDK22MTCustomAnnotationViewC11coordinatesSo22CLLocationCoordinate2DVvp)`
    
    Position of the view on the map.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public private(set) var coordinates: CLLocationCoordinate2D { get }
    ```
    
-   `[offset](#/s:11MapTilerSDK22MTCustomAnnotationViewC6offsetAA7MTPointVvp)`
    
    Offset from the center.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public private(set) var offset: MTPoint { get }
    ```
    
-   `[init(size:coordinates:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC4size11coordinatesACSo6CGSizeV_So22CLLocationCoordinate2DVtcfc)`
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public init(
        size: CGSize,
        coordinates: CLLocationCoordinate2D
    )
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>size</em></code></td><td><div><p>Size of the annotation view.</p></div></td></tr><tr><td><code><em>coordinates</em></code></td><td><div><p>Position of the annotation.</p></div></td></tr></tbody></table>
    
-   `[init(size:coordinates:offset:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC4size11coordinates6offsetACSo6CGSizeV_So22CLLocationCoordinate2DVAA7MTPointVtcfc)`
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public init(
        size: CGSize,
        coordinates: CLLocationCoordinate2D,
        offset: MTPoint
    )
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>size</em></code></td><td><div><p>Size of the annotation view.</p></div></td></tr><tr><td><code><em>coordinates</em></code></td><td><div><p>Position of the annotation.</p></div></td></tr><tr><td><code><em>offset</em></code></td><td><div><p>Offset from the center.</p></div></td></tr></tbody></table>
    
-   `[init(coder:)](#/c:@M@MapTilerSDK@objc\(cs\)MTCustomAnnotationView\(im\)initWithCoder:)`
    
    Not implemented code init.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    required public init?(coder: NSCoder)
    ```
    
-   `[setOffset(_:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC9setOffsetyyAA7MTPointVF)`
    
    Sets the offset of the annotation view in pixels.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func setOffset(_ offset: MTPoint)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>offset</em></code></td><td><div><p>Desired offset.</p></div></td></tr></tbody></table>
    
-   `[setCoordinates(_:in:completionHandler:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC14setCoordinates_2in17completionHandlerySo22CLLocationCoordinate2DV_AA05MTMapF0Cys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Sets coordinates for the view.
    
    #### 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>Position of the view</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><tr><td><code><em>mapView</em></code></td><td><div><p>Map view to apply to.</p></div></td></tr></tbody></table>
    
-   `[addTo(_:completionHandler:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC5addTo_17completionHandleryAA05MTMapF0C_ys6ResultOyytAA7MTErrorOGcSgtF)`
    
    Adds custom annotation view to the map.
    
    #### Declaration
    
    Swift
    
    ```
    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func addTo(_ mapView: MTMapView, completionHandler: ((Result<Void, MTError>) -> Void)? = nil)
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>mapView</em></code></td><td><div><p>Map view to add annotation to.</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>
    
-   `[remove()](#/s:11MapTilerSDK22MTCustomAnnotationViewC6removeyyF)`
    
    Removes custom annotation view from the map.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func remove()
    ```
    
-   `[setCoordinates(_:in:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC14setCoordinates_2inySo22CLLocationCoordinate2DV_AA05MTMapF0CtYaF)` Asynchronous
    
    Sets coordinates for the view.
    
    #### 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>Position of the view.</p></div></td></tr></tbody></table>
    
-   `[addTo(_:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC5addToyyAA05MTMapF0CYaF)` Asynchronous
    
    Adds custom annotation view to the map.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func addTo(_ mapView: MTMapView) async
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>mapView</em></code></td><td><div><p>Map view to add annotation to.</p></div></td></tr></tbody></table>
    
-   `[addToMap(_:)](#/s:11MapTilerSDK22MTCustomAnnotationViewC05addToA0yyAA05MTMapF0CF)`
    
    Adds annotation view to map DSL style.
    
    Prefer `[addTo(_:)](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTCustomAnnotationView/#/s:11MapTilerSDK22MTCustomAnnotationViewC5addToyyAA05MTMapF0CYaF)` instead.
    
    #### Declaration
    
    Swift
    
    ```
    @MainActor
    public func addToMap(_ mapView: MTMapView)
    ```
