MTTextPopup

public class MTTextPopup : MTAnnotation, MTMapViewContent, @unchecked Sendable

Basic text popup.

Can be attached to MTMarker or standalone.

  • Unique id of the popup.

    Declaration

    Swift

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

    Declaration

    Swift

    public private(set) var coordinates: CLLocationCoordinate2D { get }
  • Text content of the popup.

    Declaration

    Swift

    public private(set) var text: String { get }
  • The pixel distance from the popup’s coordinates.

    Declaration

    Swift

    public private(set) var offset: Double? { get }
  • The maximum width of the popup in pixels.

    Declaration

    Swift

    public private(set) var maxWidth: Double? { get }
  • Boolean value indicating whether the popup uses subpixel positioning.

    Declaration

    Swift

    public private(set) var isSubpixelPositioningEnabled: Bool { get }
  • Boolean value indicating whether the popup is tracking the pointer.

    Declaration

    Swift

    public private(set) var isTrackingPointer: Bool { get }
  • Boolean value indicating whether the popup is currently open on the map.

    Declaration

    Swift

    public private(set) var isOpen: Bool { get }
  • Called when the popup opens on the map.

    Declaration

    Swift

    public var onOpen: (() -> Void)?
  • Called when the popup closes from the map.

    Declaration

    Swift

    public var onClose: (() -> Void)?
  • Initializes the popup with the specified position and text.

    Declaration

    Swift

    public init(
        coordinates: CLLocationCoordinate2D,
        text: String,
        offset: Double = 0.0,
        maxWidth: Double? = nil
    )

    Parameters

    coordinates

    Position of the popup.

    text

    Text content of the popup.

  • Sets coordinates for the popup.

    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 popup

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Sets coordinates for the popup.

    Declaration

    Swift

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

    Parameters

    coordinates

    Position of the popup.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Sets the maximum width of the popup in pixels.

    Declaration

    Swift

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

    Parameters

    maxWidth

    Maximum width in pixels.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Sets the pixel offset distance from the popup’s anchor coordinate.

    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.

  • Enables or disables subpixel positioning for the popup.

    Declaration

    Swift

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

    Parameters

    isEnabled

    Boolean indicating whether subpixel positioning is enabled.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Updates the popup text content.

    Declaration

    Swift

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

    Parameters

    text

    Text content of the popup.

    mapView

    Map view to apply to.

    completionHandler

    A handler block to execute when function finishes.

  • Enables tracking the pointer position for the popup.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func trackPointer(
        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.

  • Opens the popup on the provided map view.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to add the popup to.

    completionHandler

    A handler block to execute when function finishes.

  • Closes the popup on the provided map view.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to remove the popup from.

    completionHandler

    A handler block to execute when function finishes.

  • Returns current coordinates of the popup.

    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 a Boolean value indicating whether the popup is currently open.

    Declaration

    Swift

    @available(iOS, deprecated: 16.0, message: "Prefer the async version for modern concurrency handling")
    @MainActor
    public func isOpen(
        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 popup.

    Declaration

    Swift

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

    Parameters

    coordinates

    Position of the popup.

    mapView

    Map view to apply to.

  • setLngLat(_:in:) Asynchronous

    Sets coordinates for the popup.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to apply to.

  • setMaxWidth(_:in:) Asynchronous

    Sets the maximum width of the popup in pixels.

    Declaration

    Swift

    @MainActor
    public func setMaxWidth(_ maxWidth: Double, in mapView: MTMapView) async

    Parameters

    mapView

    Map view to apply to.

  • setOffset(_:in:) Asynchronous

    Sets the pixel offset distance from the popup’s anchor coordinate.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to apply to.

  • Enables or disables subpixel positioning for the popup.

    Declaration

    Swift

    @MainActor
    public func setSubpixelPositioning(_ isEnabled: Bool, in mapView: MTMapView) async

    Parameters

    mapView

    Map view to apply to.

  • setText(_:in:) Asynchronous

    Updates the popup text content.

    Declaration

    Swift

    @MainActor
    public func setText(_ text: String, in mapView: MTMapView) async

    Parameters

    mapView

    Map view to apply to.

  • trackPointer(in:) Asynchronous

    Enables tracking the pointer position for the popup.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to apply to.

  • open(in:) Asynchronous

    Opens the popup on the provided map view.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to add the popup to.

  • close(in:) Asynchronous

    Closes the popup on the provided map view.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to remove the popup from.

  • getCoordinates(in:) Asynchronous

    Returns current coordinates of the popup.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to query.

  • isOpen(in:) Asynchronous

    Returns a Boolean value indicating whether the popup is currently open.

    Declaration

    Swift

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

    Parameters

    mapView

    Map view to query.

  • Adds popup to map DSL style.

    Prefer addTextPopup(_:) instead.

    Declaration

    Swift

    public func addToMap(_ mapView: MTMapView)