Map
@MainActor
@preconcurrency
struct Mapextension Map : MapAnimatable, Sendable, SendableMetatype, View-
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 API key to use for the Google Maps SDK.
This is required to use the Google Maps SDK.
Declaration
Swift
@MainActor @preconcurrency static var apiKey: String { get set } -
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 } -
Initializes the map view with the specified camera, mode, and content.
This method configures the map’s initial viewpoint, rendering style, and displayed content.
Declaration
Parameters
cameraThe camera position and orientation binding, defining the map’s viewport.
modeThe desired map mode (e.g.,
.hybrid,.satellite).contentThe content to be displayed on the map. This parameter is optional;
-
Initializes the map view with the specified camera, mode, and content.
This method configures the map’s initial viewpoint and rendering style.
Declaration
Parameters
initialCameraThe initial camera position and orientation, defining the map’s viewport. Defaults to a global view at {latitude: 0, longitude: 0, altitude: 63,170,000 meters}.
modeThe desired map mode (e.g.,
.hybrid,.satellite).contentThe content to be displayed on the map. This parameter is optional;
-
Returns the open source license information for the Google Maps SDK.
Declaration
Swift
@MainActor @preconcurrency static let openSourceLicenseInfo: String -
Applies a Cloud-based Map Style to the map.
Use this method to associate a unique Map ID with your map instance. Map IDs are created and managed in the Google Cloud Console. Changing the
mapIDwill trigger a full recreation of the Map view.Declaration
Swift
@MainActor @preconcurrency func style(mapID: String, error: (() -> Void)? = nil) -> MapParameters
mapIDThe unique Map ID string generated in the Google Cloud Console.
errorA closure executed if the style fails to load (e.g., due to network issues or an invalid Map ID).
Return Value
A map view configured with the specified style.
-
Enables or disables the place information card when a POI is tapped.
Declaration
Swift
@MainActor @preconcurrency func placeInformationEnabled(_ enabled: Bool = true) -> MapParameters
enabledWhether the plugin should be enabled. Defaults to
true.Return Value
The modified Map view.