0

I am using apple Map. I want to create route when user start driving.The problem is I know the starting Point and do not know end points. I read Mkdirections and use this. In this example source and destination are static

http://technet.weblineindia.com/mobile/draw-route-between-2-points-on-map-with-ios7-mapkit-api/

  MKPlacemark *source = [[MKPlacemark 

 alloc]initWithCoordinate:CLLocationCoordinate2DMake(37.776142, -122.424774)        addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil] ];

MKMapItem *srcMapItem = [[MKMapItem alloc]initWithPlacemark:source];
[srcMapItem setName:@""];

MKPlacemark *destination = [[MKPlacemark  

 alloc]initWithCoordinate:CLLocationCoordinate2DMake(37.73787, -122.373962) addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil] ];

MKMapItem *distMapItem = [[MKMapItem alloc]initWithPlacemark:destination];
[distMapItem setName:@""];

when user will be driving and location will be update again and again lat and long will be change continuously.than how to create route when user will be drive.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Lalit kumar
  • 1,797
  • 1
  • 8
  • 14
  • Can you explain a little more? Do you want a line behind the user where they've been or something different? – Hayden Holligan Dec 10 '15 at 13:38
  • Hi hayden line (route)will be create in Map when user start driving.using current location i am able to get lat and long (source point) but drawing line(route) to be need to two points source and destination.user will be drive start source points as he driving and move than lat long will be change than how to draw route – Lalit kumar Dec 10 '15 at 13:44

1 Answers1

0

Do you already know the endpoint(location) you can get them by apple

There are some nice cococontrols for it like MapManger or directions

Otherwise you must save the previous coordinates and start drawing after 2 seconden update so you can draw the way the vehicle moved

marcel
  • 313
  • 4
  • 10
  • No I am not know end point location its depends user when he will be stop driving. I know only start points – Lalit kumar Dec 10 '15 at 14:14
  • So you only can make a line between its previous point and current point. Save previous positions and start drawing if there's multiple point available. Every update of clmanager can be saved. maybe we want to have a prefdiction (http://stackoverflow.com/questions/4909380/gps-gis-calculations-algorithm-to-predict-future-position-based-on-movement-mph) – marcel Dec 10 '15 at 14:17