swiftswiftui

MapKit for SwiftUI map tiles not downloading


When I display a map and use a Marker or Annotation, none of the tiles download, and all I see is gridlines. Unless I specifically go into the Apple Maps map of the device I'm using, and look at those areas. Then when I go into the the example app, the map data shows. Is there a way to "pre-fetch" the map tiles to ensure the map shows to the user without them having to manually look at the specific location in the Apple Mapps app first? Is this by design? Or is there something else going on here?

import SwiftUI
import MapKit

struct NewYorkView: View {
    var body: some View {
        Map {
            Marker("Empire state building", coordinate: .empireStateBuilding)
                .tint(.orange)
            Annotation("Columbia University", coordinate: .columbiaUniversity) {
                ZStack {
                    RoundedRectangle(cornerRadius: 5)
                        .fill(Color.teal)
                    Text("🎓")
                        .padding(5)
                }
            }
        }
    }
}

#Preview {
    NewYorkView()
}

extension CLLocationCoordinate2D {
    static let weequahicPark = CLLocationCoordinate2D(latitude: 40.7063, longitude: -74.1973)
    static let empireStateBuilding = CLLocationCoordinate2D(latitude: 40.7484, longitude: -73.9857)
    static let columbiaUniversity = CLLocationCoordinate2D(latitude: 40.8075, longitude: -73.9626)
}

Solution

  • What I found was my per-app VPN connection was not allowing traffic from maps.apple.com.

    By adding maps.apple.com to the VPN blacklist on the MDM, it allowed me to split tunnel the maps data.