Apple MapKit Integration in iOS App
MapKit — built-in Apple framework, no keys and billing. That's the main advantage over Google Maps SDK for iOS development. But over last three major iOS versions MapKit changed substantially: SwiftUI-native Map view appeared in iOS 14 and got full annotation API only in iOS 17. If supporting iOS 15+, balance between new and old API.
MKMapView vs SwiftUI Map — What to Choose
MKMapView — mature UIKit component with full control via delegates. Map from SwiftUI simpler in basic scenarios, but before iOS 17 didn't support custom annotations in declarative style — had to wrap MKMapView via UIViewRepresentable.
For iOS 17+ SwiftUI Map with Annotation and MapPolygon covers most cases:
import MapKit
struct ContentView: View {
@State private var position: MapCameraPosition = .region(
MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 55.7558, longitude: 37.6173),
latitudinalMeters: 5000,
longitudinalMeters: 5000
)
)
var body: some View {
Map(position: $position) {
Annotation("Office", coordinate: CLLocationCoordinate2D(latitude: 55.7558, longitude: 37.6173)) {
Image(systemName: "building.2.fill")
.foregroundStyle(.blue)
.padding(8)
.background(.white)
.clipShape(Circle())
}
UserAnnotation()
}
.mapStyle(.standard(elevation: .realistic))
.mapControls {
MapUserLocationButton()
MapCompass()
MapScaleView()
}
}
}
For iOS 15-16 custom annotations — only via MKMapView + UIViewRepresentable.
MKMapView: Annotations and Delegate
class MapViewController: UIViewController, MKMapViewDelegate {
private let mapView = MKMapView()
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
mapView.frame = view.bounds
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)
let annotation = MKPointAnnotation()
annotation.coordinate = CLLocationCoordinate2D(latitude: 55.7558, longitude: 37.6173)
annotation.title = "Point A"
mapView.addAnnotation(annotation)
}
// Custom annotation view
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard !(annotation is MKUserLocation) else { return nil }
let identifier = "CustomPin"
var view = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
as? MKMarkerAnnotationView
if view == nil {
view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view?.canShowCallout = true
view?.glyphImage = UIImage(systemName: "car.fill")
view?.markerTintColor = .systemBlue
} else {
view?.annotation = annotation
}
return view
}
}
MKMarkerAnnotationView — standard view with callout support, SF Symbol glyphs and clustering via clusteringIdentifier. For fully custom view use MKAnnotationView with own UIView inside.
Routes: MKDirections
MapKit builds routes via MKDirections.Request without extra cost. Modes: .automobile, .walking, .transit (only in supported regions).
func buildRoute(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) {
let request = MKDirections.Request()
request.source = MKMapItem(placemark: MKPlacemark(coordinate: from))
request.destination = MKMapItem(placemark: MKPlacemark(coordinate: to))
request.transportType = .automobile
MKDirections(request: request).calculate { [weak self] response, error in
guard let route = response?.routes.first else { return }
self?.mapView.addOverlay(route.polyline, level: .aboveRoads)
self?.mapView.setVisibleMapRect(
route.polyline.boundingMapRect,
edgePadding: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50),
animated: true
)
}
}
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if let polyline = overlay as? MKPolyline {
let renderer = MKPolylineRenderer(polyline: polyline)
renderer.strokeColor = .systemBlue
renderer.lineWidth = 4
return renderer
}
return MKOverlayRenderer(overlay: overlay)
}
Geocoding via CLGeocoder
Without Google or Yandex — CLGeocoder and MKLocalSearch work on Apple servers:
MKLocalSearch(request: {
let req = MKLocalSearch.Request()
req.naturalLanguageQuery = "Red Square, Moscow"
req.region = mapView.region
return req
}()).start { response, _ in
guard let item = response?.mapItems.first else { return }
print(item.placemark.coordinate)
}
Important Limitations
MapKit doesn't support custom tile layers from third-party sources as flexibly as Google Maps (no direct equivalent to TileOverlayProvider for arbitrary XYZ tiles without server proxying). If offline maps or non-standard tiles needed — look at MapLibre Native or Mapbox.
Timeline
1–3 days. Basic map with annotations — 1 day. Routes, clustering, search — 2–3 days. Cost calculated individually after requirements analysis.







