Pin annotation is not showing in MKMapView when both longitude and latitude are 0

20 Views Asked by At

In MKMapView I can display my annotation with no problem using this code except when longitude and latitude are both zero

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        var view: MKPinAnnotationView
        guard let annotation = annotation as? CustomAnnotation else { return nil }

        if let dequeuedView = mapView.dequeueReusableAnnotationView(withIdentifier: annotation.identifier)
            as? MKPinAnnotationView {
            view = dequeuedView
        } else { // make a new view
            view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: annotation.identifier)
        }
    }

Still if the coordinate is shown once (long/lat # 0), then I have no issue with the pin.

Any suggestions please

0

There are 0 best solutions below