Structures
The following structures are available globally.
-
The map camera position and orientation.
Usage with the map:
// Usage with an initial camera configuration Map( initialCamera: Camera(center: LatLngAltitude(latitude: 37.7749, longitude: -122.4194, altitude: 0)), mode: .hybrid ) // Usage with a camera binding @State private var camera = Camera(center: LatLngAltitude(latitude: 37.7749, longitude: -122.4194, altitude: 0)) Map(camera: $camera, mode: .hybrid)Usage with fly animations:
struct FlyAnimationExample: View { @State private var animationTrigger = 0 let targetCamera = Camera(center: LatLngAltitude(latitude: 37.7749, longitude: -122.4194, altitude: 0)) var body: some View { Map(mode: .hybrid) .flyCameraTo(targetCamera, trigger: animationTrigger) .flyCameraAround(targetCamera, trigger: animationTrigger) } }Declaration
Swift
struct Cameraextension Camera : AdditiveArithmetic, Animatable, Copyable, Equatable, Escapable, VectorArithmetic -
A control that displays a compass which rotates with the map’s current camera heading, and re-orients the map to face north when tapped.
Add a compass to the map using the
mapControlsmodifier:Map(mode: .hybrid) .mapControls { CompassControl() }Declaration
Swift
@MainActor @preconcurrency struct CompassControlextension CompassControl : MapControl, Sendable, SendableMetatype, View -
Declaration
Swift
struct LatLngAltitudeextension LatLngAltitude : AdditiveArithmetic, Animatable, Copyable, Equatable, Escapable, Hashable, VectorArithmetic -
Represents a rectangular region on the Earth’s surface defined by latitude and longitude ranges.
Bounds can restrict both longitude and latitude, or can restrict either latitude or longitude only. For latitude-only bounds use longitude range of
(-180.0)...180. For longitude-only bounds use latitude range of-(90)...90.Declaration
Swift
struct LatLngBounds -
Declaration
Swift
@MainActor @preconcurrency struct Mapextension Map : MapAnimatable, Sendable, SendableMetatype, View -
Constructs map controls.
MapControlsBuilderis used in themapControlsview modifier to allow for a natural, declarative syntax when specifying multiple controls.Declaration
Swift
@resultBuilder struct MapControlsBuilder -
The result of a tap gesture on a map.
Declaration
Swift
struct MapTapInfo -
A type that allows you to display custom SwiftUI content over the Map, anchored to a position on the 3D map.
Default content is a
Pinview.Map(mode: .hybrid) { Marker(position: .init(latitude: 37.7749, longitude: -122.4194, altitude: 0)) { Image(systemName: "car") } }Declaration
Swift
@MainActor @preconcurrency struct Marker<Content> where Content : Viewextension Marker : MapContent, MapContentAnchorable, Sendable, SendableMetatype, View -
A 3D marker that can be placed on a map.
Map(mode: .hybrid) { Marker3D(position: .init(latitude: 37.7749, longitude: -122.4194, altitude: 0)) }Declaration
Swift
@MainActor @preconcurrency struct Marker3Dextension Marker3D : MapContent, MapContentAnchorable, MapContentTappable, Sendable, SendableMetatype, View -
A 3D model that can be placed on a map.
Map(mode: .hybrid) { Model( position: .init(latitude: 37.7749, longitude: -122.4194, altitude: 100), url: URL(string: "path/to/your/model.glb")! ) }Declaration
Swift
@MainActor @preconcurrency struct Modelextension Model : MapContent, MapContentTappable, Sendable, SendableMetatype, View -
Declaration
Swift
struct Orientation3Dextension Orientation3D : Equatable, Hashable -
A control that allows the user to pan the map horizontally (left and right).
Map(mode: .hybrid) .mapControls { PanHorizontalControl() }Declaration
Swift
@MainActor @preconcurrency struct PanHorizontalControlextension PanHorizontalControl : MapControl, Sendable, SendableMetatype, View -
A control that allows the user to pan the map vertically (up and down).
Map(mode: .hybrid) .mapControls { PanVerticalControl() }Declaration
Swift
@MainActor @preconcurrency struct PanVerticalControlextension PanVerticalControl : MapControl, Sendable, SendableMetatype, View -
A SwiftUI view that renders a map pin.
The appearance of the pin, including its background color, border color, scale, and glyph, can be customized using a
Pin.Configurationobject.Pinis used internally byMarker3Ds with the.pinstyle, and as a SwiftUI view with theMarkertype.Examples customizing a
PinforMarker:Marker(position: .init(latitude: 0, longitude: 0)) { Pin(configuration: .init(backgroundColor: .blue, borderColor: .black)) } Marker(position: .init(latitude: 0, longitude: 0)) { Pin(configuration: .red) }Declaration
Swift
@MainActor @preconcurrency struct Pinextension Pin : Sendable, SendableMetatype, View -
A 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), ] ) }Declaration
Swift
@MainActor @preconcurrency struct Polygonextension Polygon : MapContent, MapContentTappable, Sendable, SendableMetatype, View -
Represents the geometry definition for a polygon with an outer boundary and optional inner boundaries.
Map(mode: .hybrid) { Polygon( geometry: PolygonGeometry(path: [ .init(latitude: 37.7749, longitude: -122.4194, altitude: 100), .init(latitude: 37.7750, longitude: -122.4193, altitude: 100), .init(latitude: 37.7751, longitude: -122.4192, altitude: 100), ]) ) }Declaration
Swift
struct PolygonGeometryextension PolygonGeometry : Equatable, Hashable -
A 3D polyline that can be placed on a map.
Map(mode: .hybrid) { Polyline(path: [ .init(latitude: 37.7749, longitude: -122.4194, altitude: 100), .init(latitude: 37.7750, longitude: -122.4193, altitude: 100), .init(latitude: 37.7751, longitude: -122.4192, altitude: 100), ]) }Declaration
Swift
@MainActor @preconcurrency struct Polylineextension Polyline : MapContent, MapContentTappable, Sendable, SendableMetatype, View -
A SwiftUI view that displays content in a “popover” bubble, anchored to a position or another piece of map content on the 3D map.
Declaration
Swift
@MainActor @preconcurrency struct Popover<Content> where Content : Viewextension Popover : MapContent, Sendable, SendableMetatype, View -
Configuration for the visual appearance of a Popover.
Declaration
Swift
struct PopoverStyleextension PopoverStyle : Equatable -
A control that allows the user to rotate the map.
Map(mode: .hybrid) .mapControls { RotateControl() }Declaration
Swift
@MainActor @preconcurrency struct RotateControlextension RotateControl : MapControl, Sendable, SendableMetatype, View -
Configuration for the shadow of a Popover.
Declaration
Swift
struct Shadowextension Shadow : Equatable -
A control that allows the user to tilt the map.
Map(mode: .hybrid) .mapControls { TiltControl() }Declaration
Swift
@MainActor @preconcurrency struct TiltControlextension TiltControl : MapControl, Sendable, SendableMetatype, View -
Declaration
Swift
struct Vector3Dextension Vector3D : Equatable, Hashable -
A control that allows the user to zoom in and out of the map.
Map(mode: .hybrid) .mapControls { ZoomControl() }Declaration
Swift
@MainActor @preconcurrency struct ZoomControlextension ZoomControl : MapControl, Sendable, SendableMetatype, View