0

から一連の目印を受け取っています:

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    ..
}

を使用してコンソールに印刷する場合NSLog、目印は次の形式でデータを提供します。

..HIDDEN .. St.、Brighton、MA 02135、United States @ <+42.HIDDEN、-71.HIDDEN> +/- 100.00m

しかし、次のコードを使用すると、ボストンが都市になります

[placemark.addressDictionary objectForKey:(NSString*)kABPersonAddressCityKey]);

ブライトンはボストンの一部ですが、コンソールログに市のキーよりも具体的な場所を表示するにはどうすればよいですか。

4

1 に答える 1

0

目印でできる最善のことは

[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

この投稿はiOSで役立つ可能性があります:CLLocationManagerを使用して正確な逆ジオコーディングを取得しますか?

ブライトンの代わりにボストンを使用することは、同じ場所の有効な住所であることに注意してください。

http://support.apple.com/kb/HT1975

これは私のために働いた:

- (void) resetLocationData{
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
    [locationManager startUpdatingLocation];
    NSLog(@"LAT: %f", [locationManager location].coordinate.latitude);
    NSString *latitude = [NSString stringWithFormat:@"%f", [locationManager location].coordinate.latitude];
    NSString *longitude = [NSString stringWithFormat:@"%f", [locationManager location].coordinate.longitude];
    NSString *latlong = [NSString stringWithFormat:@"%@,%@", latitude, longitude];
    NSLog(@"LONG: %f", [locationManager location].coordinate.longitude);
    NSLog(@"Combined Location: %@", latlong);

    [[locationManager location]timestamp];
}


#pragma mark - CLLOCATION STUFF
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    self.currentLocation = newLocation;
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];

    [geocoder reverseGeocodeLocation:self.currentLocation completionHandler:^(NSArray *placemarks, NSError *error)
     {

         NSLog(@"Placemark is %@", placemarks);
         CLPlacemark *place = [placemarks objectAtIndex:0];
        NSLog(@"placemark 0: %@", place);

        // locationLabel.text = placemarks;

     }];
    if(newLocation.horizontalAccuracy <= 100.0f) {
        [locationManager stopUpdatingLocation];
    }
}

ログ出力:

2013-01-13 23:23:05.508 CLLocationTest [47617:907]目印は( "XX XXXXXX Rd、XX XXXXXX Rd、Brighton、MA 02135、United States @ <+ 42.XXXXXX、-71.XXXXXXX> +/- 100.00m」

于 2013-01-14T03:32:17.450 に答える