MTMarker

public class MTMarker : MTAnnotation, MTMapViewContent, @unchecked Sendable

Annotation element that can be added to the map.

  • Unique id of the marker.

    Declaration

    Swift

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

    Declaration

    Swift

    public private(set) var coordinates: CLLocationCoordinate2D { get }
  • Color of the marker.

    Declaration

    Swift

    public var color: UIColor?
  • Boolean indicating whether marker is draggable.

    Declaration

    Swift

    public var draggable: Bool?
  • Custom icon to use for marker.

    Declaration

    Swift

    public var icon: UIImage?
  • Optional attached popup.

    Declaration

    Swift

    public private(set) var popup: MTTextPopup? { get }
  • Optional attached custom annotation.

    Declaration

    Swift

    weak public private(set) var annotationView: MTCustomAnnotationView? { get }
  • Initializes the marker with the specified position.

    Declaration

    Swift

    public init(coordinates: CLLocationCoordinate2D)

    Parameters

    coordinates

    Position of the marker.

  • Initializes the marker with the specified position and text popup.

    Declaration

    Swift

    public init(coordinates: CLLocationCoordinate2D, popup: MTTextPopup?)

    Parameters

    coordinates

    Position of the marker.

    popup

    Popup to attach to the marker.

  • Initializes the marker with the specified position, color/icon and behaviour.

    Declaration

    Swift

    public init(
        coordinates: CLLocationCoordinate2D,
        color: UIColor? = .blue,
        icon: UIImage? = nil,
        draggable: Bool? = false
    )

    Parameters

    coordinates

    Position of the marker.

    color

    Color of the marker.

    icon

    Icon for the marker.

    draggable

    Boolean indicating whether the marker is draggable.

  • Sets coordinates for the marker.

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

    completionHandler

    A handler block to execute when function finishes.

  • Sets marker as map’s delegate.

    Declaration

    Swift

    @MainActor
    public func setDelegate(to mapView: MTMapView)

    Parameters

    mapView

    Map view for which to subscribe to.

  • Attaches custom annotation view to the marker.

    Note

    Does not add the custom view to the map. Use customAnnotationView.addTo.

    Declaration

    Swift

    public func attachAnnotationView(_ view: MTCustomAnnotationView)
  • setCoordinates(_:in:) Asynchronous

    Sets coordinates for the marker.

    Declaration

    Swift

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

    Parameters

    coordinates

    Position of the marker.

    mapView

    Map view to apply to.

  • Adds marker to map DSL style.

    Prefer addMarker(_:) instead.

    Declaration

    Swift

    public func addToMap(_ mapView: MTMapView)
  • Modifier. Sets the popup.

    Note

    Not to be used outside of DSL.

    Declaration

    Swift

    @discardableResult
    public func popup(_ value: MTTextPopup) -> Self