I am using MapKit
to show two annotations and distance between them. Everything works fine but I keep getting this error on the console.
MobileGestalt.c:1647: Could not retrieve region info
Anybody knows what is causing it? Could it be some permission in the .plist
file
Here is full console output:
2019-11-10 00:21:41.419108+0100 Post DACH[20420:264466] Metal API Validation Enabled
2019-11-10 00:21:41.567416+0100 Post DACH[20420:264466] libMobileGestalt MobileGestalt.c:1647: Could not retrieve region info
My code:
struct MapView: UIViewRepresentable {
var requestLocation: CLLocationCoordinate2D
var destinationLocation: CLLocationCoordinate2D
private let mapView = WrappableMapView()
func makeUIView(context: UIViewRepresentableContext<MapView>) -> MKMapView {
mapView.delegate = mapView
return mapView
}
func updateUIView(_ uiView: MKMapView, context: UIViewRepresentableContext<MapView>) {
let requestAnnotation = MKPointAnnotation()
requestAnnotation.coordinate = requestLocation
requestAnnotation.title = "Package"
uiView.addAnnotation(requestAnnotation)
let destinationAnnotation = MKPointAnnotation()
destinationAnnotation.coordinate = destinationLocation
destinationAnnotation.title = "Destiantion"
uiView.addAnnotation(destinationAnnotation)
let sourcePlacemark = MKPlacemark(coordinate: requestLocation)
let destinationPlacemark = MKPlacemark(coordinate: destinationLocation)
let directionRequest = MKDirections.Request()
directionRequest.source = MKMapItem(placemark: sourcePlacemark)
directionRequest.destination = MKMapItem(placemark: destinationPlacemark)
directionRequest.transportType = .automobile
let directions = MKDirections(request: directionRequest)
directions.calculate { (response, error) in
guard let directionResponse = response else {
if let error = error {
print(error.localizedDescription)
}
return
}
let route = directionResponse.routes[0]
uiView.addOverlay(route.polyline, level: .aboveRoads)
let rect: MKMapRect = route.polyline.boundingMapRect
uiView.setVisibleMapRect(rect, edgePadding: .init(top: 50.0, left: 50.0, bottom: 50.0, right: 50.0), animated: true)
}
}
}
You might have missed setting MKMapView delegate in your code.
Try setting mapView.delegate = self
in your view where you have delegate methods implemented.
I ran into the same issue today. It appears that it's an issue with the simulator. Try running it in your device and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With