ユーザーの正確な現在の住所(国、州、市)を取得する必要があります。そこで、緯度と経度を見つけて、逆ジオコーディングを使って調べましたが、緯度と経度自体を取得することはできません。xcode4.1を使用して、iPhoneシミュレーターでテストしています。
これは私が取り組んでいるコードです:
- (void)viewDidLoad
{
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
NSLog(@"%@", [self deviceLocation]);
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
latLabel.text = lat;
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
longLabel.text = longt;
}
緯度と経度を見つけてユーザーの住所を見つけるにはどうすればよいですか?
編集:
私のバージョンをXcode4.5に更新しました。しかし、それでも場所を見ることができませんでした....?Yそうですか?