article

Sunday, August 8, 2021

SwiftUI MapKit Example

SwiftUI MapKit Example
SwiftUI a Map view can be displayed showing a map inside the main view.
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
//  ContentView.swift
//  swiftuidev
//
//  Created by Cairocoders
//
 
import SwiftUI
import MapKit
 
struct ContentView: View {
    @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 14.836620, longitude: 120.294113) , span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
     
    var body: some View {
        Map(coordinateRegion: $region)
            .edgesIgnoringSafeArea(.all)
    }
}
 
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Related Post