0

Possible Duplicate:
How to add “Directions To Here” button into the address book?

I am using Address Book API to show contact info in my app. The info includes name, phone number, and address.

I want to add a "Directions to Here" button as it used to appear in Google Maps app. Can that be done with ABPersonViewController that I am using?

My question is the same as this one: How to add "Directions To Here" button into the address book?

I dont see clear answer here.

Community
  • 1
  • 1
user984248
  • 149
  • 1
  • 1
  • 8

1 Answers1

1

First, you have to convert the address into a coordinate. Not hard, you can use forward geocoding since iOS 5. There are also APIs that will forward geocode an address for you if you don't want to use Apple's Map Kit.

Once you get the latitude and longitude of the destination, and your starting point, you can either calculate yourself the route, or just use some third party API. The Google Directions API is excellent. Google will return a JSON or XML composed response with all the information for the computed routes. You can also set params like if you want to include tolls routes, and so on. Take a look at the documentation.

Also, you might like to take a look at this toy app a few months ago. You will find pretty much everything you need, from forward geocoding, to route request, route processing (you have to extract for the google response all the information needed to draw the lines into a map), and then the map drawing.

Ariel Rodriguez
  • 211
  • 1
  • 4
  • 1
    Very good answer, Thank you! However, I don't necessarily want to build the routing portion of it. I just want a button that will launch the maps app from my app. – user984248 Oct 10 '12 at 18:35