来自国家/地区名称的坐标/区域

时间:2012-04-13 06:32:00

标签: objective-c ios xcode mapkit core-location

如何根据正确编写的国家/地区名称提取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保持告诉地址的变量是什么?

1 个答案:

答案 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);

    }


}];