Marker
@MainActor
@preconcurrency
struct Marker<Content> where Content : Viewextension Marker : MapContent, MapContentAnchorable, Sendable, SendableMetatype, ViewA type that allows you to display custom SwiftUI content over the Map, anchored to a position on the 3D map.
Default content is a Pin view.
Map(mode: .hybrid) {
Marker(position: .init(latitude: 37.7749, longitude: -122.4194, altitude: 0)) {
Image(systemName: "car")
}
}
-
The type of view representing the body of this view.
When you create a custom view, Swift infers this type from your implementation of the required
View/body-swift.propertyproperty.Declaration
Swift
typealias Body = some View -
The altitude interpretation for the
position.Declaration
Swift
@MainActor @preconcurrency let altitudeMode: AltitudeMode -
The content and behavior of the view.
When you implement a custom view, you must implement a computed
bodyproperty to provide the content for your view. Return a view that’s composed of built-in views that SwiftUI provides, plus other composite views that you’ve already defined:struct MyView: View { var body: some View { Text("Hello, World!") } }For more information about composing views and a view hierarchy, see doc:Declaring-a-Custom-View.
Declaration
Swift
@MainActor @preconcurrency var body: some View { get } -
Creates a Marker anchored to a specific coordinate.
Declaration
Swift
@MainActor @preconcurrency init(position: LatLngAltitude, altitudeMode: AltitudeMode = .clampToGround, collisionBehavior: CollisionBehavior = .required, collisionPriority: Int? = nil, @ViewBuilder content: () -> Content = { Pin() })Parameters
positionThe geographic coordinate to anchor to.
altitudeModeThe altitude interpretation for the
position. Default value:.clampToGround.collisionBehaviorThe collision behavior of the Marker. Default value:
.required.collisionPriorityA number which is used to help determine relative priority between optional collision behavior markers. A higher collisionPriority value indicates higher priority.
contentThe SwiftUI view to display inside the Marker. Default value:
Pin(). -
The geographic coordinate to anchor the Marker to.
Declaration
Swift
@MainActor @preconcurrency let position: LatLngAltitude