0

I was wondering if anyone knew how to get a list of addresses around a longitude and latitude?

I've been using the following code but it always yields one address:

[self.geocoder reverseGeocodeLocation: currentLocation  completionHandler:
 ^(NSArray *placemarks, NSError *error) {
     for (int i = 0; i < placemarks.count; i++)
     {
         CLPlacemark *placemark = [placemarks objectAtIndex:i];
         if (placemark.addressDictionary != nil)
         {
             Location *aLocation = [[Location alloc] init];
             aLocation.locationName = [placemark.addressDictionary valueForKey:@"Name"];
             aLocation.locationAddress = [placemark.addressDictionary valueForKey:@"City"];
             aLocation.currentLocation = placemark.location;
             [self.tableData addObject:aLocation];
         }
     }
    [self.locationsTableView reloadData];
 }];
Mikerizzo
  • 557
  • 1
  • 4
  • 22
  • check this question http://stackoverflow.com/questions/158557/get-street-address-at-lat-long-pair – Spire Mar 12 '13 at 15:21
  • http://stackoverflow.com/questions/13557026/can-you-create-an-annotation-in-mapview-from-an-address/13564318#13564318 – Rajneesh071 Mar 12 '13 at 15:37
  • What kind of addresses are you looking for? Do you want all mailing addresses or just specific landmarks (places)? – Jeffrey May 09 '13 at 19:37

2 Answers2

0

I'm not sure if Core Location's geocoded is intended to do that.

Google allows for this kind of search but with limits with their Places API. That being said, you can do a search for something like "Pizza" and get results within a radius.

For more info look at: https://developers.google.com/places/documentation/

You can use their API to query based on a lat/long with a search query and radius to get results looking like what you're after.

Good luck!

SushiGrass Jacob
  • 19,278
  • 1
  • 23
  • 39
0

First change your latitude and longitude value (and check may be your code is right) becoze in map, some coordinate does not provide full information.

following provide code for if some coordinate does not provide full information then how can give you condition for get specific CITY(or other Infor) name.
Here getReverseGeocode method call by [self getReverseGeocode];

- (void) getReverseGeocode
    {
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];

        if(currentLatLong.count > 0)
        {
            CLLocationCoordinate2D myCoOrdinate;

            myCoOrdinate.latitude = LatValue;
            myCoOrdinate.longitude = LangValue;

            CLLocation *location = [[CLLocation alloc] initWithLatitude:myCoOrdinate.latitude longitude:myCoOrdinate.longitude];
            [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
             {
                 if (error)
                 {
                     NSLog(@"failed with error: %@", error);
                     return;
                 }
                 if(placemarks.count > 0)
                 {
                     NSString *MyAddress = @"";
                     NSString *city = @"";

                     if([placemark.addressDictionary objectForKey:@"FormattedAddressLines"] != NULL)
                         MyAddress = [[placemark.addressDictionary objectForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
                     else
                         MyAddress = @"Address Not founded";

                     if([placemark.addressDictionary objectForKey:@"SubAdministrativeArea"] != NULL)
                         city = [placemark.addressDictionary objectForKey:@"SubAdministrativeArea"];
                     else if([placemark.addressDictionary objectForKey:@"City"] != NULL)
                         city = [placemark.addressDictionary objectForKey:@"City"];
                     else if([placemark.addressDictionary objectForKey:@"Country"] != NULL)
                         city = [placemark.addressDictionary objectForKey:@"Country"];
                     else
                         city = @"City Not founded";

                   NSLog(@"%@",city);
                   NSLog(@"%@", MyAddress);
                 }
             }];
        }
    }
iPatel
  • 41,165
  • 13
  • 109
  • 131