我使用API中的坐标在地图上添加注释,但它没有出现在:
谁能告诉我如何修复它?谢谢! 这是我的代码:
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)
}
}
答案 0 :(得分:0)
请尝试以下代码:
DispatchQueue.main.async {
let annotation = MKPointAnnotation()
let coordinate = self.provider.parks[0].coordinate
annotation.coordinate = coordinate
annotation.title = "title"
annotation.subtitle = "subtitle"
self.mapView?.addAnnotation(annotation)
}