views:

28

answers:

2

Hi Guys,

I am developing application based on geocoder. In my app, to get the user current address, i am using placemark address dictionary method inside geocode delegate method and then, i could able to get all the details (street, city, state, county, countrycode and all) except postalcode. Why postal code is not coming?. Now i am working with iOS 4. please help me out.

my code,

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark    *)placemark
 {  
      placemark = [[MKPlacemark alloc] initWithCoordinate:locationManager.location.coordinate addressDictionary:[placemark addressDictionary]];

      NSLog(@"Address Dictionary %@", [placemark addressDictionary]);

      NSDictionary * addressDict= [placemark addressDictionary];

      country = [addressDict objectForKey:@"Country"];

      postal = [addressDict objectForKey:@"PostalCode"];

      state = [addressDict objectForKey:@"State"];

      city = [addressDict objectForKey:@"City"];

 }

This is my current address, which is from placemark address dictionary.

Address Dictionary {
City = Madurai;
Country = India;
CountryCode = IN;
FormattedAddressLines =     (
    "Lady Doak College Rd, Chinna Chokkikulam, Chockikulam",
    "Madurai, Tamil Nadu",
    India
);
State = "Tamil Nadu";
Street = "Lady Doak College Rd";
SubAdministrativeArea = Madurai;
SubLocality = "Chinna Chokkikulam";
Thoroughfare = "Lady Doak College Rd";
}

in above code, there is no poastalCode. but i need postal code. to get a postal code, What i want to do? please give a solution .

A: 

You may be able to use a free Reverse Geocoding service to do this for you.

Google has such a service: http://code.google.com/apis/maps/documentation/services.html#ReverseGeocoding

Alternately, this Google Groups post has a listing of other Reverse Geocoding services: http://groups.google.com/group/Google-Maps-API/web/resources-non-google-geocoders?pli=1

dkk
A: 

Hi Guys,

I have solved my problem via remove the below line and there is no necessary to init placemark.

 placemark = [[MKPlacemark alloc] initWithCoordinate:locationManager.location.coordinate addressDictionary:[placemark addressDictionary]];
Sivanathan