开发者

Why postal code is not coming on address dictionary?

开发者 https://www.devze.com 2023-01-14 18:26 出处:网络
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 a

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 .


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


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]];
0

精彩评论

暂无评论...
验证码 换一张
取 消