【发布时间】:2019-10-28 06:41:38
【问题描述】:
我有一个 CLLocationCoordinates2D 数组并设置了一个 for 循环来调用函数 get_addres_from_geoCoder 但是这个函数只打印一个地址,而 CLLocationCoordinates2D 数组有 18 个值(纬度,经度)
override func viewDidLoad() {
super.viewDidLoad()
for a in My_rides_Pick_locatio
{
let loc = CLLocationCoordinate2D(latitude:a.latitude,longitude: a.longitude)
self.get_addres_from_geoCoder(loc: loc)
}
func get_addres_from_geoCoder(loc : CLLocationCoordinate2D) {
let location: CLLocation = CLLocation(latitude: loc.latitude, longitude: loc.longitude)
geo.reverseGeocodeLocation(location as CLLocation, preferredLocale: nil) { (clPlacemark: [CLPlacemark]?, error: Error?) in
guard let place = clPlacemark?.first else {
print("No placemark from Apple: \(String(describing: error))")
return
}
print("----")
print(place.compactAddress!)
}
}
}
结果
R A Bazaar 路,拉瓦尔品第,巴基斯坦
【问题讨论】:
标签: ios arrays swift google-maps reverse-geocoding