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? -
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 -
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 )Parameters
coordinatesPosition of the marker.
anchorAnchor position for the marker.
offsetPixel 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 )Parameters
coordinatesPosition of the marker.
popupPopup to attach to the marker.
anchorAnchor position for the marker.
offsetPixel 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 )Parameters
coordinatesPosition of the marker.
colorColor of the marker.
iconIcon for the marker.
draggableBoolean indicating whether the marker is draggable.
anchorAnchor position for the marker.
offsetPixel 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 )Parameters
coordinatesPosition of the marker.
colorColor of the marker.
iconIcon for the marker.
draggableBoolean indicating whether the marker is draggable.
popupPopup to attach to the marker.
anchorAnchor position for the marker.
offsetPixel offset from the anchor applied on both axes.
-
Sets coordinates for the marker.
Declaration
Parameters
coordinatesPosition of the marker.
completionHandlerA handler block to execute when function finishes.
-
Sets marker as map’s delegate.
Declaration
Swift
@MainActor public func setDelegate(to mapView: MTMapView)Parameters
mapViewMap 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() -
setCoordinates(_:Asynchronousin: ) Sets coordinates for the marker.
Declaration
Swift
@MainActor public func setCoordinates(_ coordinates: CLLocationCoordinate2D, in mapView: MTMapView) asyncParameters
coordinatesPosition of the marker.
mapViewMap 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