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?
  • Opacity of the marker.

    Declaration

    Swift

    public var opacity: Double
  • Opacity applied when the marker is covered by another object.

    Declaration

    Swift

    public var opacityWhenCovered: Double
  • Boolean indicating whether marker is draggable.

    Declaration

    Swift

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

    Declaration

    Swift

    public var icon: UIImage?
  • Anchor position of the marker.

    Declaration

    Swift

    public var anchor: MTAnchor
  • Offset distance from the marker’s anchor, applied on both axes in pixels.

    Declaration

    Swift

    public var offset: Double
  • Scale factor applied to the marker.

    Declaration

    Swift

    public var scale: Double
  • Enables subpixel positioning when rendering the marker.

    Declaration

    Swift

    public var subpixelPositioning: Bool
  • Rotation of the marker in degrees.

    Declaration

    Swift

    public var rotation: Double
  • Alignment of the marker rotation relative to the map or viewport.

    Declaration

    Swift

    public var rotationAlignment: MTMarkerRotationAlignment
  • Alignment of the marker pitch relative to the map or viewport.

    Declaration

    Swift

    public var pitchAlignment: MTMarkerPitchAlignment
  • 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,
        anchor: MTAnchor = .center,
        offset: Double = 0.0,
        opacity: Double = 1.0,
        opacityWhenCovered: Double = 0.2,
        rotation: Double = 0.0,
        rotationAlignment: MTMarkerRotationAlignment = .auto,
        pitchAlignment: MTMarkerPitchAlignment = .auto,
        scale: Double = 1.0,
        subpixelPositioning: Bool = true
    )

    Parameters

    coordinates

    Position of the marker.

    anchor

    Anchor position for the marker.

    offset

    Pixel offset from the anchor applied on both axes.

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

    Declaration

    Swift

    public init(
        coordinates: CLLocationCoordinate2D,
        popup: MTTextPopup?,
        anchor: MTAnchor = .center,
        offset: Double = 0.0,
        opacity: Double = 1.0,
        opacityWhenCovered: Double = 0.2,
        rotation: Double = 0.0,
        rotationAlignment: MTMarkerRotationAlignment = .auto,
        pitchAlignment: MTMarkerPitchAlignment = .auto,
        scale: Double = 1.0,
        subpixelPositioning: Bool = true
    )

    Parameters

    coordinates

    Position of the marker.

    popup

    Popup to attach to the marker.

    anchor

    Anchor position for the marker.

    offset

    Pixel offset from the anchor applied on both axes.

  • 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,
        anchor: MTAnchor = .center,
        offset: Double = 0.0,
        opacity: Double = 1.0,
        opacityWhenCovered: Double = 0.2,
        rotation: Double = 0.0,
        rotationAlignment: MTMarkerRotationAlignment = .auto,
        pitchAlignment: MTMarkerPitchAlignment = .auto,
        scale: Double = 1.0,
        subpixelPositioning: Bool = true
    )

    Parameters

    coordinates

    Position of the marker.

    color

    Color of the marker.

    icon

    Icon for the marker.

    draggable

    Boolean indicating whether the marker is draggable.

    anchor

    Anchor position for the marker.

    offset

    Pixel offset from the anchor applied on both axes.

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

    Declaration

    Swift

    public init(
        coordinates: CLLocationCoordinate2D,
        color: UIColor? = .blue,
        icon: UIImage? = nil,
        draggable: Bool? = false,
        popup: MTTextPopup?,
        anchor: MTAnchor = .center,
        offset: Double = 0.0,
        opacity: Double = 1.0,
        opacityWhenCovered: Double = 0.2,
        rotation: Double = 0.0,
        rotationAlignment: MTMarkerRotationAlignment = .auto,
        pitchAlignment: MTMarkerPitchAlignment = .auto,
        scale: Double = 1.0,
        subpixelPositioning: Bool = true
    )

    Parameters

    coordinates

    Position of the marker.

    color

    Color of the marker.

    icon

    Icon for the marker.

    draggable

    Boolean indicating whether the marker is draggable.

    popup

    Popup to attach to the marker.

    anchor

    Anchor position for the marker.

    offset

    Pixel offset from the anchor applied on both axes.

  • 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)
  • Detaches custom annotation view from the marker.

    Declaration

    Swift

    public func detachAnnotationView()
  • Sets whether the marker is draggable.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setDraggable(
        _ draggable: Bool,
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )

    Parameters

    draggable

    Boolean indicating whether the marker should be draggable.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Sets the offset distance from the marker’s anchor.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setOffset(
        _ offset: Double,
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )

    Parameters

    offset

    Pixel offset applied on both axes.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Sets the rotation of the marker in degrees.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setRotation(
        _ rotation: Double,
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )

    Parameters

    rotation

    Rotation in degrees.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Sets the rotation alignment of the marker.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func setRotationAlignment(
        _ alignment: MTMarkerRotationAlignment,
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )

    Parameters

    alignment

    Rotation alignment relative to map or viewport.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Toggles the popup bound to the marker.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func togglePopup(
        in mapView: MTMapView,
        completionHandler: ((Result<Void, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Returns current coordinates of the marker.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getCoordinates(
        in mapView: MTMapView,
        completionHandler: ((Result<CLLocationCoordinate2D, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to query.

    completionHandler

    A handler block to execute when function finishes.

  • Returns the marker’s pitch alignment.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getPitchAlignment(
        in mapView: MTMapView,
        completionHandler: ((Result<MTMarkerPitchAlignment, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to query.

    completionHandler

    A handler block to execute when function finishes.

  • Returns the marker’s rotation value.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getRotation(
        in mapView: MTMapView,
        completionHandler: ((Result<Double, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to query.

    completionHandler

    A handler block to execute when function finishes.

  • Returns the marker’s rotation alignment.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getRotationAlignment(
        in mapView: MTMapView,
        completionHandler: ((Result<MTMarkerRotationAlignment, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to query.

    completionHandler

    A handler block to execute when function finishes.

  • Returns the marker’s offset value in pixels.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func getOffset(
        in mapView: MTMapView,
        completionHandler: ((Result<Double, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to query.

    completionHandler

    A handler block to execute when function finishes.

  • Returns whether the marker is draggable.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func isDraggable(
        in mapView: MTMapView,
        completionHandler: ((Result<Bool, MTError>) -> Void)? = nil
    )

    Parameters

    mapView

    Map view to query.

    completionHandler

    A handler block to execute when function finishes.

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

  • setDraggable(_:in:) Asynchronous

    Sets whether the marker is draggable.

    Declaration

    Swift

    @MainActor
    public func setDraggable(_ draggable: Bool, in mapView: MTMapView) async

    Parameters

    draggable

    Boolean indicating whether the marker should be draggable.

    mapView

    Map view to apply to.

  • setOffset(_:in:) Asynchronous

    Sets the offset distance from the marker’s anchor.

    Declaration

    Swift

    @MainActor
    public func setOffset(_ offset: Double, in mapView: MTMapView) async

    Parameters

    offset

    Pixel offset applied on both axes.

    mapView

    Map view to apply to.

  • setRotation(_:in:) Asynchronous

    Sets the rotation of the marker in degrees.

    Declaration

    Swift

    @MainActor
    public func setRotation(_ rotation: Double, in mapView: MTMapView) async

    Parameters

    rotation

    Rotation in degrees.

    mapView

    Map view to apply to.

  • Sets the rotation alignment of the marker.

    Declaration

    Swift

    @MainActor
    public func setRotationAlignment(_ alignment: MTMarkerRotationAlignment, in mapView: MTMapView) async

    Parameters

    alignment

    Rotation alignment relative to map or viewport.

    mapView

    Map view to apply to.

  • togglePopup(in:) Asynchronous

    Toggles the popup bound to the marker.

    Declaration

    Swift

    @MainActor
    public func togglePopup(in mapView: MTMapView) async

    Parameters

    mapView

    Map view to apply to.

  • getCoordinates(in:) Asynchronous

    Returns current coordinates of the marker.

    Declaration

    Swift

    @MainActor
    public func getCoordinates(in mapView: MTMapView) async -> CLLocationCoordinate2D

    Parameters

    mapView

    Map view to query.

  • getPitchAlignment(in:) Asynchronous

    Returns the marker’s pitch alignment.

    Declaration

    Swift

    @MainActor
    public func getPitchAlignment(in mapView: MTMapView) async -> MTMarkerPitchAlignment

    Parameters

    mapView

    Map view to query.

  • getRotation(in:) Asynchronous

    Returns the marker’s rotation value.

    Declaration

    Swift

    @MainActor
    public func getRotation(in mapView: MTMapView) async -> Double

    Parameters

    mapView

    Map view to query.

  • Returns the marker’s rotation alignment.

    Declaration

    Swift

    @MainActor
    public func getRotationAlignment(in mapView: MTMapView) async -> MTMarkerRotationAlignment

    Parameters

    mapView

    Map view to query.

  • getOffset(in:) Asynchronous

    Returns the marker’s offset value in pixels.

    Declaration

    Swift

    @MainActor
    public func getOffset(in mapView: MTMapView) async -> Double

    Parameters

    mapView

    Map view to query.

  • isDraggable(in:) Asynchronous

    Returns whether the marker is draggable.

    Declaration

    Swift

    @MainActor
    public func isDraggable(in mapView: MTMapView) async -> Bool

    Parameters

    mapView

    Map view to query.

  • 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