When 500m is specified in MKCoordinateRegion, it stops with an error.

I used Xcode 14 Beta 2.

It worked fine on Xcode 13.

If you set it to 3000m as shown below, it will work without problems.

Below is the sample code.

import SwiftUI
import MapKit

enum MapType {
  case standard
  case satellite
  case hybrid
  case satelliteFlyover
  case hybridFlyover
  case mutedStandard
}

struct MapView: UIViewRepresentable {
  let searchKey: String
   
  let mapType: MapType

  func makeUIView(context: Context) -> MKMapView {
    return MKMapView()
  }
   
  func updateUIView(_ uiView: MKMapView, context: Context) {

    switch mapType {
    case .standard:
      uiView.preferredConfiguration = MKStandardMapConfiguration(elevationStyle: .flat)
       
    case .satellite:
      uiView.preferredConfiguration = MKImageryMapConfiguration()

    case .hybrid:
      uiView.preferredConfiguration = MKHybridMapConfiguration()

    case .satelliteFlyover:
      uiView.preferredConfiguration = MKImageryMapConfiguration(elevationStyle: .realistic)

    case .hybridFlyover:
      uiView.preferredConfiguration = MKHybridMapConfiguration(elevationStyle: .realistic)

    case .mutedStandard:
      uiView.preferredConfiguration = MKStandardMapConfiguration(emphasisStyle: .muted)

    }

    let geocoder = CLGeocoder()
     
    geocoder.geocodeAddressString(searchKey) { placemarks, error in
      if let placemarks,
        let firstPlaceMark = placemarks.first ,
        let location = firstPlaceMark.location {
         
        let targetCoordinate = location.coordinate
         
        print(targetCoordinate)
         
        let pin = MKPointAnnotation()
         
        pin.coordinate = targetCoordinate
         
        pin.title = searchKey

        uiView.addAnnotation(pin)

        uiView.region = MKCoordinateRegion(center: targetCoordinate,
                          latitudinalMeters: 3000.0,
                          longitudinalMeters: 3000.0)
      }
    }
  }
}
Accepted Answer

I'm having the same error but with a MKCoordinateSpan. This is my code:

let span = MKCoordinateSpan(latitudeDelta: 0.005, longitudeDelta: 0.005)

...

let currentRegion = MKCoordinateRegion(center: lastCoordinate, span: span)

I hope they will release a fix, right now I have to change the latitude and longitude delta to 0.05 and everything works fine.

Cheers.

This is happening to me as well, these were my deltas, MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01), however, moving them one decimal lower to 0.1 solved my issue and allowed the preview to build as well as the simulator to stop crashing.

Thank you!

This happens in the simulator. I transferred the app to my iPhone and it worked fine.

When 500m is specified in MKCoordinateRegion, it stops with an error.
 
 
Q