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 } -
init(coordinates:anchor: offset: opacity: opacityWhenCovered: rotation: rotationAlignment: pitchAlignment: scale: subpixelPositioning: ) 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
coordinatesPosition of the marker.
anchorAnchor position for the marker.
offsetPixel offset from the anchor applied on both axes.
-
init(coordinates:popup: anchor: offset: opacity: opacityWhenCovered: rotation: rotationAlignment: pitchAlignment: scale: subpixelPositioning: ) 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
coordinatesPosition of the marker.
popupPopup to attach to the marker.
anchorAnchor position for the marker.
offsetPixel offset from the anchor applied on both axes.
-
init(coordinates:color: icon: draggable: anchor: offset: opacity: opacityWhenCovered: rotation: rotationAlignment: pitchAlignment: scale: subpixelPositioning: ) 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
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.
-
init(coordinates:color: icon: draggable: popup: anchor: offset: opacity: opacityWhenCovered: rotation: rotationAlignment: pitchAlignment: scale: subpixelPositioning: ) 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
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() -
Sets whether the marker is draggable.
Declaration
Parameters
draggableBoolean indicating whether the marker should be draggable.
mapViewMap view to apply to.
completionHandlerA handler block to execute when function finishes.
-
Sets the offset distance from the marker’s anchor.
Declaration
Parameters
offsetPixel offset applied on both axes.
mapViewMap view to apply to.
completionHandlerA handler block to execute when function finishes.
-
Sets the rotation of the marker in degrees.
Declaration
Parameters
rotationRotation in degrees.
mapViewMap view to apply to.
completionHandlerA 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
alignmentRotation alignment relative to map or viewport.
mapViewMap view to apply to.
completionHandlerA handler block to execute when function finishes.
-
Toggles the popup bound to the marker.
Declaration
Parameters
mapViewMap view to apply to.
completionHandlerA handler block to execute when function finishes.
-
Returns current coordinates of the marker.
Declaration
Parameters
mapViewMap view to query.
completionHandlerA 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
mapViewMap view to query.
completionHandlerA handler block to execute when function finishes.
-
Returns the marker’s rotation value.
Declaration
Parameters
mapViewMap view to query.
completionHandlerA 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
mapViewMap view to query.
completionHandlerA handler block to execute when function finishes.
-
Returns the marker’s offset value in pixels.
Declaration
Parameters
mapViewMap view to query.
completionHandlerA handler block to execute when function finishes.
-
Returns whether the marker is draggable.
Declaration
Parameters
mapViewMap view to query.
completionHandlerA handler block to execute when function finishes.
-
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.
-
setDraggable(_:Asynchronousin: ) Sets whether the marker is draggable.
Declaration
Swift
@MainActor public func setDraggable(_ draggable: Bool, in mapView: MTMapView) asyncParameters
draggableBoolean indicating whether the marker should be draggable.
mapViewMap view to apply to.
-
setOffset(_:Asynchronousin: ) Sets the offset distance from the marker’s anchor.
Declaration
Swift
@MainActor public func setOffset(_ offset: Double, in mapView: MTMapView) asyncParameters
offsetPixel offset applied on both axes.
mapViewMap view to apply to.
-
setRotation(_:Asynchronousin: ) Sets the rotation of the marker in degrees.
Declaration
Swift
@MainActor public func setRotation(_ rotation: Double, in mapView: MTMapView) asyncParameters
rotationRotation in degrees.
mapViewMap view to apply to.
-
setRotationAlignment(_:Asynchronousin: ) Sets the rotation alignment of the marker.
Declaration
Swift
@MainActor public func setRotationAlignment(_ alignment: MTMarkerRotationAlignment, in mapView: MTMapView) asyncParameters
alignmentRotation alignment relative to map or viewport.
mapViewMap view to apply to.
-
togglePopup(in:Asynchronous) Toggles the popup bound to the marker.
Declaration
Swift
@MainActor public func togglePopup(in mapView: MTMapView) asyncParameters
mapViewMap view to apply to.
-
getCoordinates(in:Asynchronous) Returns current coordinates of the marker.
Declaration
Swift
@MainActor public func getCoordinates(in mapView: MTMapView) async -> CLLocationCoordinate2DParameters
mapViewMap view to query.
-
getPitchAlignment(in:Asynchronous) Returns the marker’s pitch alignment.
Declaration
Swift
@MainActor public func getPitchAlignment(in mapView: MTMapView) async -> MTMarkerPitchAlignmentParameters
mapViewMap view to query.
-
getRotation(in:Asynchronous) Returns the marker’s rotation value.
Declaration
Swift
@MainActor public func getRotation(in mapView: MTMapView) async -> DoubleParameters
mapViewMap view to query.
-
getRotationAlignment(in:Asynchronous) Returns the marker’s rotation alignment.
Declaration
Swift
@MainActor public func getRotationAlignment(in mapView: MTMapView) async -> MTMarkerRotationAlignmentParameters
mapViewMap view to query.
-
getOffset(in:Asynchronous) Returns the marker’s offset value in pixels.
Declaration
Swift
@MainActor public func getOffset(in mapView: MTMapView) async -> DoubleParameters
mapViewMap view to query.
-
isDraggable(in:Asynchronous) Returns whether the marker is draggable.
Declaration
Swift
@MainActor public func isDraggable(in mapView: MTMapView) async -> BoolParameters
mapViewMap 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