Tag: geocoding

对多个位置进行地理编码 – 了解何时调用“所有”完成块

我正在使用CoreLocation的地理编码器来获取多个地图项的CLLocation坐标。 地理编码器在完成时为每个项目调用完成块。 当所有包含asynchronous地理编码调用的调用完成后,如何创build一个类似的块function? (我可以使用手动计数器,但必须有一个更优雅的解决scheme) 这是我迄今为止的地理编码function。 它通过一系列位置项目进行循环,并为每个项目启动一个新的地理编码过程。 -(void)geoCodeAllItems { for (EventItem* thisEvent in [[EventItemStore sharedStore] allItems]) { if (![thisEvent eventLocationCLLocation]){ //Only geocode if the item has no location data yet CLGeocoder *geocoder = [[CLGeocoder alloc]init]; [geocoder geocodeAddressString:[thisEvent eventLocationGeoQuery] completionHandler:^(NSArray *placemarks, NSError *error) { if (error){ NSLog(@"\t Geo Code – Error – Failed to geocode"; return; } […]