Post marked as solved
Post marked as solved with 2 replies, 4,569 views
How to change map type to satellite in SwiftUI
I’m trying to help my son learn SwiftUI. We’re going through the tutorial provided by Apple. After playing around with the basic app they have you build, he decided he wanted to set the map view to satellite mode. Is there a way to do that in SwiftUI?
This is the code he’s working with. We’re running Xcode version 11.5 on Catalina. Sorry I don’t have too much knowledge in this area
import SwiftUI
import MapKit
struct MapView: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
MKMapView(frame: .zero)
}
func updateUIView(_ uiView: MKMapView, context: Context) {
let coordinate = CLLocationCoordinate2D(latitude: -2.1230, longitude: -80.0438)
let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region = MKCoordinateRegion(center: coordinate, span: span)
uiView.setRegion(region, animated: true)
}
}
struct MapView_Previews: PreviewProvider {
static var previews: some View {
MapView()
}
}