1

)

I'm trying to put a direction polyline on a MKMapView in my iOS project, using Google Directions API. I used the code found in this blog : http://iosguy.com/2012/05/22/tracing-routes-with-mapkit/ , which works quite well. But the problem I find is that the polyline do not follow the roads, instead it draws lines straight from one point to another :-(

Can anyone please help me to make it follow the roads ? Thanks :-)

01Human
  • 11
  • 3
  • 1
    I had written, of course, a "Hi :-)" at the beginning of this question, but it disappeared... So here I put it again... – 01Human Sep 10 '12 at 06:06

1 Answers1

2

Instead of using the coordinates of the route steps, you can use the *overview_polyline* element of the Google Directions response to draw a smooth line following the roads. You can use this code to decode the polyline string: https://gist.github.com/3770235

edit: I erroneously made the assumption you where using the steps coordinates, as that is usually the cause of these straight lines, but the link you post already uses the *overview_polyline*. In that case my answer is probably not solving your problem. Decoding the polyline as a category on MKPolyline could be a nice addition to your code though.

Mux
  • 143
  • 1
  • 4