MapType

Guys how is it possible to set a map type like hybrid, satellite etc on the following code? Thanks in advance!

import MapKit

struct MapView: View {    

    @State private var region: MKCoordinateRegion = {

        

        var mapCoordinates = CLLocationCoordinate2D(latitude: 6.600286, longitude: 16.4377599)

        var mapZoomLevel  = MKCoordinateSpan(latitudeDelta: 70.0, longitudeDelta: 70.0)

        

        var mapRegion = MKCoordinateRegion(center: mapCoordinates, span: mapZoomLevel)

        return mapRegion

    } ()

    

    let locations: [NationalParkLocation] = Bundle.main.decode("locations.json")

    var body: some View {

              Map(coordinateRegion: $region, annotationItems: locations, annotationContent: { item in

     

            MapAnnotation(coordinate: item.location) {

                Image("logo")

                    .resizable()

                    .scaledToFit()

                    .frame(width: 32, height: 32, alignment: .center)

            }             

        })

      }

}

Replies

I hope this solves your problem;

.onAppear() {
       MKMapView.appearance().mapType = .hybrid               
     }