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.

  • Unique id of the source.

    Declaration

    Swift

    public var identifier: String
  • url

    URL that points to an image.

    Declaration

    Swift

    public var url: URL?
  • Corners of image specified as CLLocationCoordinate2D. Clockwise order: top-left, top-right, bottom-right, bottom-left.

    Declaration

    Swift

    public var coordinates: [CLLocationCoordinate2D]
  • Type of the source.

    Declaration

    Swift

    public private(set) var type: MTSourceType { get }
  • Initializes the image source with required values.

    Declaration

    Swift

    public init(identifier: String, url: URL, coordinates: [CLLocationCoordinate2D])

    Parameters

    identifier

    Unique id of the source.

    url

    URL to the image resource.

    coordinates

    Corners of image in clockwise order using CLLocationCoordinate2D.

Operations

  • 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

    coordinates

    New corners of the image using CLLocationCoordinate2D.

    mapView

    MTMapView which holds the source.

    completionHandler

    A handler block to execute when function finishes.

  • 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

    url

    New image URL.

    coordinates

    New corners of the image using CLLocationCoordinate2D.

    mapView

    MTMapView which holds the source.

    completionHandler

    A handler block to execute when function finishes.

Concurrency

  • setCoordinates(_:in:) Asynchronous

    Updates the coordinates of the image source.

    Declaration

    Swift

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

    Parameters

    coordinates

    New corners of the image using CLLocationCoordinate2D.

    mapView

    MTMapView which holds the source.

  • Updates the image URL and coordinates simultaneously.

    Declaration

    Swift

    @MainActor
    public func updateImage(url: URL, coordinates: [CLLocationCoordinate2D], in mapView: MTMapView) async

    Parameters

    url

    New image URL.

    coordinates

    New corners of the image using CLLocationCoordinate2D.

    mapView

    MTMapView which holds the source.

DSL