MTCustomAnnotationView

@MainActor
open class MTCustomAnnotationView : UIView, @preconcurrency MTMapViewContent, @preconcurrency MTAnnotation, @unchecked Sendable

Subclassable view for adding custom annotations to the map.

  • Unique id of the view.

    Declaration

    Swift

    @MainActor
    public private(set) var identifier: String { get }
  • Position of the view on the map.

    Declaration

    Swift

    @MainActor
    public private(set) var coordinates: CLLocationCoordinate2D { get }
  • Offset from the center.

    Declaration

    Swift

    @MainActor
    public private(set) var offset: MTPoint { get }
  • Declaration

    Swift

    @MainActor
    public init(
        frame: CGRect,
        coordinates: CLLocationCoordinate2D
    )

    Parameters

    frame

    Frame of the annotation view.

    coordinates

    Position of the annotation.

  • Declaration

    Swift

    @MainActor
    public init(
        frame: CGRect,
        coordinates: CLLocationCoordinate2D,
        offset: MTPoint
    )

    Parameters

    frame

    Frame of the annotation view.

    coordinates

    Position of the annotation.

    offset

    Offset from the center.

  • Initializes the view with the frame and centered coordinates.

    Declaration

    Swift

    @MainActor
    public override init(frame: CGRect)

    Parameters

    frame

    Frame of the annotation view.

  • Not implemented code init.

    Declaration

    Swift

    @MainActor
    required public init?(coder: NSCoder)
  • Sets the offset of the annotation view in pixels.

    Declaration

    Swift

    @MainActor
    public func setOffset(_ offset: MTPoint)

    Parameters

    offset

    Desired offset.

  • 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

    coordinates

    Position of the view

    completionHandler

    A handler block to execute when function finishes.

    mapView

    Map view to apply to.

  • 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

    mapView

    Map view to add annotation to.

    completionHandler

    A handler block to execute when function finishes.

  • Removes custom annotation view from the map.

    Declaration

    Swift

    @MainActor
    public func remove()
  • setCoordinates(_:in:) Asynchronous

    Sets coordinates for the view.

    Declaration

    Swift

    @MainActor
    public func setCoordinates(_ coordinates: CLLocationCoordinate2D, in mapView: MTMapView) async

    Parameters

    coordinates

    Position of the view.

  • addTo(_:) Asynchronous

    Adds custom annotation view to the map.

    Declaration

    Swift

    @MainActor
    public func addTo(_ mapView: MTMapView) async

    Parameters

    mapView

    Map view to add annotation to.

  • Adds annotation view to map DSL style.

    Prefer addTo(_:) instead.

    Declaration

    Swift

    @MainActor
    public func addToMap(_ mapView: MTMapView)