Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapKit MobileGestalt.c:1647: Could not retrieve region info

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

Screenshot

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)
        }

    }
}
like image 561
M1X Avatar asked Nov 09 '19 23:11

M1X


2 Answers

You might have missed setting MKMapView delegate in your code.

Try setting mapView.delegate = self in your view where you have delegate methods implemented.

like image 121
jegadeesh Avatar answered Nov 01 '22 06:11

jegadeesh


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.

like image 2
MVZ Avatar answered Nov 01 '22 05:11

MVZ