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:
I want to allow the user to change the map type (satellite, etc...).
Is there a way to set the map type in SwiftUI?
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.
You can change the style of the map by using MapStyle
like that :
Map {
// your content
}.mapStyle(.imagery)
You have some styles available :
standard
: The default options. Only show few roads and some names.imagery
: The satellite view onlyhybrid
: A mix of both, the satellite view with some roads, names and others useful stuffIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With