Polygon
@MainActor
@preconcurrency
struct Polygonextension Polygon : MapContent, MapContentTappable, Sendable, SendableMetatype, ViewA 3D polygon that can be placed on a map.
Map(mode: .hybrid) {
Polygon(
path: [
.init(latitude: 37.7749, longitude: -122.4194, altitude: 0),
.init(latitude: 37.7740, longitude: -122.4184, altitude: 0),
.init(latitude: 37.7750, longitude: -122.4174, 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 -
Declaration
-
Specifies how altitudes in the path are interpreted. Default value: clampToGround.
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 } -
Represents the polygon’s shape.
Declaration
Swift
@MainActor @preconcurrency let geometry: PolygonGeometry -
Initializes a polygon with a polygon geometry.
Declaration
Swift
@MainActor @preconcurrency init(geometry: PolygonGeometry, altitudeMode: AltitudeMode = .clampToGround, zIndex: Int32 = 0)Parameters
geometryThe
PolygonGeometrythat defines the polygon’s shape.altitudeModeSpecifies how altitudes in the path are interpreted. Default value: .clampToGround.
zIndexThe draw order compared to other polygons. Default value: 0.
-
Initializes a polygon with a path and optional inner paths.
Declaration
Swift
@MainActor @preconcurrency init(path: [LatLngAltitude], innerPaths: [[LatLngAltitude]] = [], altitudeMode: AltitudeMode = .clampToGround, zIndex: Int32 = 0)Parameters
pathThe array of
LatLngAltitudedefining the outer boundary of the polygon.innerPathsAn array of arrays of
LatLngAltitude, each defining an inner boundary (hole) within the polygon. Defaults to an empty array.altitudeModeSpecifies how altitudes in the path are interpreted. Default value: .clampToGround.
zIndexThe draw order compared to other polygons. Default value: 0.
-
Declaration
Swift
@MainActor @preconcurrency func style(_ style: Polygon.StyleOptions) -> Polygon -
Style options of the polygon.
Declaration
Swift
@MainActor @preconcurrency var styleOptions: Polygon.StyleOptions -
The draw order compared to other polys. Default value: 0.
Declaration
Swift
@MainActor @preconcurrency let zIndex: Int32