Search code examples
mapkitios6-mapsgoogle-local-search

iOS6 MapKit (MKLocalSearch): How to get Address of a mapItem?


iOS6 Apple MapKit

So I understand the code in the link below for the most part. http://phpadvocate.com/blog/2013/01/ios-6-1-simple-example-using-mklocalsearch/

However, how do I get the address for the mapItem? Seems like the other properties include: placemark, isCurrentLocation, name, phoneNumber, and url.

http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapItem_class/MKMapItem_class.pdf

Basically, once the data is fetched, I'd like to display the name of the retail location as the cell.text and the address as cell.detailText.


Solution

  • mapItem.placemark.thoroughfare.copy, // Will return first single line address

    mapItem.placemark.locality, // Will return City

    mapItem.placemark.administrativeArea //Will return State.

    Below are some more:

    CLPlacemark | Property Meaning

    Thoroughfare | Street address. First line if multiple lines.

    subThoroughfare | Street address, second line (e.g., apartment or unit number, box number)

    Locality | City

    SubLocality | This might contain a neighborhood or landmark name, though it’s often nil

    administrativeArea | State, province, territory, or other similar unit

    dministrativeArea | County

    postalCode | ZIP code

    Country | Country

    countryCode | Two-digit ISO country code