ViewAnnotation

@_documentation(visibility: public)
@_spi(Experimental)
public struct ViewAnnotation : MapContent

Displays view annotation.

Create a view annotation to display SwiftUI view in Map content.

Map {
    ViewAnnotation(CLLocationCoordinate2D(...)) {
       Text("🚀")
          .background(Circle().fill(.red))
    }
}
  • Creates a view annotation.

    Declaration

    Swift

    @available(iOS 13.0, *)
    @_documentation(visibility: public)
    public init<Content: View>(
        _ coordinate: CLLocationCoordinate2D,
        allowOverlap: Bool = false,
        anchor: ViewAnnotationAnchor = .center,
        offsetX: CGFloat? = nil,
        offsetY: CGFloat? = nil,
        @ViewBuilder content: @escaping () -> Content
    )

    Parameters

    coordinate

    Coordinate the view annotation is bound to.

    allowOverlap

    If true, the annotation will be visible even if it collides with other annotations. Defaults to false.

    anchor

    Specifies where the annotation will be located relatively to the given coordinate.

    offsetX

    Additional X offset, positive values move annotation to right.

    offsetY

    Additional Y offset, positive values move annotation to top.