Open Xcode and either click Create a new Xcode project in Xcode’s startup window, or choose File > New > Project.
In the template selector, select iOS as the platform, select the Single View Apptemplate, and then click Next.
Enter “MapView” as the Product Name, select the Use SwiftUI checkbox, and click Next. Choose a location to save the project on your Mac.
In Canvas on the right click Resume to display the preview. If the canvas is hidden select Editor > Editor and Canvas to show it.
After creating project MapKit needs to be imported and UIViewRepresentable protocol declared.
There might be errors regarding the adopted protocol , we will fix them in the next steps. This error is due to UIViewRepresentable protocol which has two requirements you need to add: a makeUIView(context:) method that creates an MKMapView, and an updateUIView(_:context:) method that configures the view and responds to any changes.
Replace the body property with a makeUIView(context:) method that creates and returns an empty MKMapView.
The next step is to create an updateUIView(_:context:) method that sets the map view’s region to the correct coordinates to center the map on Apple’s headquarters. Because MKMapView is a UIView subclass, you’ll need to switch to a live preview to see the map.
CLLocationCoordinate2D - The latitude and longitude associated with a location, specified using the WGS 84 reference frame.
MKCoordinateSpan - Delta values are used in this structure to indicate the desired zoom level of the map, with smaller delta values corresponding to a higher zoom level.