Nassif
Nassif

Reputation: 1223

CLGeoCoder doesnot return the exact data for the current location

In the simulator I set the location to

Latitude: 38.056709
Longitude: -78.6115

but the placemark that returns is of Virginia.

CLGeocoder *geocoder = [[CLGeocoder alloc] init];

[geocoder reverseGeocodeLocation: APP_DELEGATE.userLocation completionHandler:^(NSArray *placemarks, NSError *error)
{
    if([placemarks count] > 0)
    {
        CLPlacemark *placemark = [placemarks objectAtIndex:0];
        NSLog(@"placemark --- %@",placemark);
    }
}];

"App.userlocation" is the location that I get after updating the locationmanager

This is what I get in the console:

placemark ----
{
    City = "Charlottesville";
    Country = "United States";
    CountryCode = US;
    FormattedAddressLines = ("704 Grassmere Rd",
                             "Charlottesville",
                             "VA 22903-9214",
                             "United States");

    Name = "704 Grassmere Rd";
    PostCodeExtension = 9214;
    State = "Virginia";
    Street = "704 Grassmere Rd";
    SubAdministrativeArea = "Albemarle";
    SubLocality = "Samuel Miller";
    SubThoroughfare = 704;
    Thoroughfare = "Grassmere Rd";
    ZIP = 22903;
}

Upvotes: 0

Views: 140

Answers (1)

Aluminum
Aluminum

Reputation: 2992

Check your coordinates, that's what Google Maps says for your coordinates:

Latitude: 38.056709
Longitude: -78.6115

enter image description here

CLGeocoder is actually right since those coordinates points in Virginia not District Columbia

Upvotes: 1

Related Questions