Я буксирую UIViewControllers. Первый отображает MKMapKitView с аннотациями и текущим местоположением пользователя, а во втором viewController я буду конструировать аннотации, которые будут отображаться для первого viewController.
Я нашел что если местоположение пользователя и аннотации совпадают, mapView будет отображать только текущее местоположение пользователя.
Вот мой код для создания аннотации:
func addAnnotiation(for locationCoordinate: CLLocationCoordinate2D) {
let annotationPoint = MKPointAnnotation()
annotationPoint.coordinate = locationCoordinate
mapView.addAnnotation(annotationPoint)
}
Мой MKMapViewDelegate
метод :
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let identifier = "Annotation"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView!.canShowCallout = true
} else {
annotationView!.annotation = annotation
}
return annotationView
}
Как я могу решить эту проблему, чтобы, если аннотация и местоположение пользователя были одинаковыми, отображались также аннотации, а не только текущее местоположение пользователя?