2012-04-13 103 views
2

如何根據正確書寫的國家名稱提取CLRegionCLLocationCoordinate2D或緯度/經度點?將CLGeocoder這樣的工作:國家名稱的座標/區域

CLGeocoder *geoCode = [[CLGeocoder alloc] init]; 
[geoCode geocodeAddressString:@"Singapore" completionHandler:^(NSArray *placemarks,  NSError *error) { 
if (!error) { 
     CLPlacemark *place = [placemarks objectAtIndex:0]; 
NSLog(@"%i,%i", place.//what would i put here); 

} 


    }]; 

什麼變量做了CLPlacemark保持告訴的地址?

回答

3

沒關係想通了:

CLGeocoder *geoCode = [[CLGeocoder alloc] init]; 
[geoCode geocodeAddressString:@"Singapore" completionHandler:^(NSArray *placemarks, NSError *error) { 
    if (!error) { 
     CLPlacemark *place = [placemarks objectAtIndex:0]; 
     CLLocation *location = place.location; 
     CLLocationCoordinate2D coord = location.coordinate; 
     NSLog(@"%g is latitude and %g is longtitude", coord.latitude, coord.longitude); 

    } 


}]; 
相關問題