0Pricing
Swift Academy · Lesson

Displaying Maps in SwiftUI

Show maps and annotations with Map.

The SwiftUI Map View

SwiftUI provides a native Map view (in MapKit) for displaying interactive maps without UIKit. Import MapKit and place a Map in your view hierarchy. Since iOS 17 it uses a modern, declarative API.

import SwiftUI
import MapKit

struct BasicMap: View {
    var body: some View {
        Map()
    }
}

Coordinate Regions

A region is described by an MKCoordinateRegion — a center coordinate plus a span (how much latitude/longitude is visible). Smaller spans zoom in closer.

let region = MKCoordinateRegion(
    center: CLLocationCoordinate2D(latitude: 41.008, longitude: 28.978),
    span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)
)

All lessons in this course

  1. Requesting Location Authorization
  2. Getting the User's Location
  3. Displaying Maps in SwiftUI
  4. Geocoding and Regions
← Back to Swift Academy