如何根据正确编写的国家/地区名称提取CLRegion
或CLLocationCoordinate2D
或纬度/经度点? 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
保持告诉地址的变量是什么?
答案 0 :(得分:4)
没关系弄明白:
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);
}
}];