1

IN my project I need to draw a route between two pins. Can anyone tell me what are the methods used. And give me the example code for that.

lostInTransit
  • 70,519
  • 61
  • 198
  • 274
raja
  • 9
  • 3

3 Answers3

1

Try these posts.. It will help you i think

http://navarra.ca/?p=786

http://spitzkoff.com/craig/?p=108

This will automatically use Google Direction API and will fetch the points in between the locations i guess..

Anyhow see this blog http://laurilarjo.wordpress.com/2010/10/23/using-google-directions-api-and-drawing-routes-in-iphone-mkmapview/

ipraba
  • 16,485
  • 4
  • 59
  • 58
0

You can use MKPolyLineView - it allows you to draw a line (or polyline, if you need several segments) as an overlay on top of the MKMapView. Apple even has example code using this here.

Note that this method uses an MKOverlayView which was added in iOS 4, so it only works in iOS 4+. If you need to target iOS 3 devices, then you can use the MKAnnotationView hack that others have linked to (originating as far as I can tell from that spitzkoff blog post). I used to do it that way, but did away with it when iOS 4 had matured enough - I'd wholeheartedly recommend doing it the new way if you don't need iOS 3 support.

As for pins, use MKPinAnnotationView

Martin Gjaldbaek
  • 2,987
  • 4
  • 20
  • 29
-1

Go to google maps. "Get directions". Make a screenshot. Then use UIImageView. This is what I would do.

debleek63
  • 1,181
  • 8
  • 17