Marker3D
@MainActor
@preconcurrency
struct Marker3Dextension Marker3D : MapContent, MapContentAnchorable, MapContentTappable, Sendable, SendableMetatype, ViewA 3D marker that can be placed on a map.
Map(mode: .hybrid) {
Marker3D(position: .init(latitude: 37.7749, longitude: -122.4194, altitude: 0))
}
-
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 -
Defines the visual style and content of a
Marker3D.Declaration
Swift
struct Style -
Specifies how altitude in the position is interpreted.
Default value:
clampToGroundDeclaration
Swift
@MainActor @preconcurrency var 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 } -
Specifies how a
Marker3Dshould behave when it collides with anotherMarker3Dor with the default map labels.Default value:
requiredDeclaration
Swift
@MainActor @preconcurrency var collisionBehavior: CollisionBehavior -
Specifies whether this Marker3D should be drawn or not when it’s occluded. The Marker3D can be occluded by map geometry (e.g. buildings).
Default value:
falseDeclaration
Swift
@MainActor @preconcurrency var drawsWhenOccluded: Bool -
Specifies whether to connect the Marker3D to the ground. To extrude a Marker3D, the altitudeMode must be either
relativeToGround,relativeToMeshorabsolute.Default value:
falseDeclaration
Swift
@MainActor @preconcurrency var extruded: Bool -
init(position:altitudeMode:collisionBehavior:extruded:drawsWhenOccluded:sizePreserved:zIndex:label:style:)
Creates a new Marker3D.
Declaration
Swift
@MainActor @preconcurrency init(position: LatLngAltitude, altitudeMode: AltitudeMode = .clampToGround, collisionBehavior: CollisionBehavior = .required, extruded: Bool = false, drawsWhenOccluded: Bool = false, sizePreserved: Bool = false, zIndex: Int32 = 0, label: String = "", style: Marker3D.Style = .default)Parameters
positionThe position of the Marker3D.
altitudeModeSpecifies how altitude in the position is interpreted. Default value:
clampToGroundcollisionBehaviorSpecifies how a
Marker3Dshould behave when it collides with anotherMarker3Dor with the default map labels. Default value:requiredextrudedSpecifies whether to connect the Marker3D to the ground. To extrude a Marker3D, the altitudeMode must be either
relativeToGround,relativeToMeshorabsolute. Default value:falsedrawsWhenOccludedSpecifies whether this Marker3D should be drawn or not when it’s occluded. The Marker3D can be occluded by map geometry (e.g. buildings). Default value:
falsesizePreservedSpecifies whether this Marker3D should preserve its size or not regardless of distance from camera. By default the Marker3D is scaled based on distance from camera/tilt. Default value:
falsezIndexThe zIndex compared to other 3D Marker3Ds. By default,
Marker3Dsare displayed according to their vertical position on screen, with lowerMarker3Dsappearing in front ofMarker3Dfarther up the screen. Note thatzIndexis also used to help determine relative priority betweenCollisionBehavior.optionalAndHidesLowerPriority3D Marker3Ds. A higherzIndexvalue indicates higher priority. Default value:0`labelText to be displayed by this Marker3D. Defaults to empty string.
styleThe style of the Marker3D.
-
Text to be displayed by this Marker3D.
Defaults to empty string.
Declaration
Swift
@MainActor @preconcurrency var label: String -
Sets the position.
Declaration
Swift
@MainActor @preconcurrency var position: LatLngAltitude -
Specifies whether this Marker3D should preserve its size or not regardless of distance from camera. By default the Marker3D is scaled based on distance from camera/tilt.
Default value:
falseDeclaration
Swift
@MainActor @preconcurrency var sizePreserved: Bool -
The zIndex compared to other 3D Marker3Ds. By default,
Marker3Dsare displayed according to their vertical position on screen, with lowerMarker3Ds appearing in front ofMarker3Dfarther up the screen. Note thatzIndexis also used to help determine relative priority betweenCollisionBehavior.optionalAndHidesLowerPriority3D Marker3Ds. A higherzIndexvalue indicates higher priority.Default value:
0Declaration
Swift
@MainActor @preconcurrency var zIndex: Int32