I used coordinate from API to put an annotation on map, but it didn't show up while:
- I declared a new coordinate which is not from API, can show up on map.
- I can print the coordinate form API, and the coordinate was fine.
- I put mapView.addAnnotation() in DispatchQueue.main.async.
Can anyone tell me how to fix it? Thanks! Here is my code:
extension LocationViewController: ParkProviderDelegate {
func didFetch(by provider: ParkProvider) {
DispatchQueue.main.async {
let annotation = MKPointAnnotation()
let coordinate = self.provider.parks[0].coordinate
self.mapView?.addAnnotation(annotation)
}
}