'SwiftUI: change map type on map view?

I am adding a map view like this:

            Map(coordinateRegion: $coordinateRegion)
                                .frame(height: 400, alignment: .center)
                                .cornerRadius(5)
                                .shadow(radius: 4)

Map shows up as this:

enter image description here

I want to allow the user to change the map type (satellite, etc...).

Is there a way to set the map type in SwiftUI?



Solution 1:[1]

As for now I fear that you have to access the mapType using

MKMapView.appearance().mapType = .satellite // or any other map type

You can use it just onAppear. I am not sure if there is a better way, but at least it works :)

For more detailed specifications the UIKit Mapview is needed for now.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1