MCK*_*pur 3 xcode objective-c core-location mapkit ios
如何根据正确书写的国家/地区名称提取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);
}
}];
Run Code Online (Sandbox Code Playgroud)
CLPlacemark告诉地址的变量是什么?
没关系想通了:
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);
}
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1289 次 |
| 最近记录: |