swiftuimapkit

How to 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

  • 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.