0
私は、reverseGeocodeLocation関数を使用して座標(これは私がピンポイントに使用する)をアドレスに変換しています。reverseGeocodeLocationの目印を取得できません。func Swift 3
すると、私はこのコードを作ってみた:
func displayMarkers(/*completion: @escaping (CLPlacemark!)->()*/)
{
let annotationView = MKAnnotationView()
var integerCount = 0
let detailButton: UIButton = UIButton(type: .detailDisclosure)
annotationView.rightCalloutAccessoryView = detailButton
let geoCoder = CLGeocoder()
getFromDatabase { (locs) in
// Hier is "locs" de [CLLocationCoordinate2D] array
for location in locs{
let loca = CLLocation(latitude: location.latitude, longitude: location.longitude)
geoCoder.reverseGeocodeLocation(loca){placemarks, error in
var placemark : CLPlacemark!
placemark = placemarks?[0]
//let streetname = (placemark.addressDictionary?["Street"])
//let city = (placemark.addressDictionary?["City"])
//let cityAndStreet = "\(streetname!) \(city!)"
//completion(placemark)
}
//self.displayMarkers { (allPlacemarks) in
//let streetname = (allPlacemarks.addressDictionary?["Street"])
//let city = (allPlacemarks.addressDictionary?["City"])
//let cityAndStreet = "\(streetname!) \(city!)"
let annotation = MKPointAnnotation()
annotation.coordinate = location
annotation.title = "Taxi \(integerCount)"
annotation.subtitle = ""
self.mapView.addAnnotation(annotation)
}
integerCount = integerCount + 1
}
}
私の質問は、私が働いて完了を取得することはできません(私はそれをコメントアウト)。 このようにこの補完を使用すると、displayMarkers()を呼び出すviewdidloadにエラーが発生します。エラーは、私が持っていない引数を入れる必要があると言います。
私はannotation.subtitleにアドレスを入れることができるので、他の方法で私はそこから使用可能な情報を得ることができますか?私は本当にここにそれがうれしいでしょう!