i want to get the route between the two point in the mapkit!
i had done some google work n found this :-http://spitzkoff.com/craig/?p=108
I had used this to display map and pin:-
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBarHidden=NO;
self.title=@"Map";
CLLocationCoordinate2D location;
location.latitude=[latLabel doubleValue];
location.longitude=[longLabel doubleValue];
MKCoordinateRegion region;// = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake((location.latitude) / 2.0, (location.longitude) / 2.0), 1000.0, 1000.0);
region.center=location;
region.span.latitudeDelta =0.1;
region.span.longitudeDelta =0.1;
addAnnotation=[[AddressAnnotation alloc] initWithCoordinate:location];
NSLog(@"city=mapview=>%@",City);
NSLog(@"adress=mapview=>%@",Address);
addAnnotation.title=City;
addAnnotation.subtitle=Address;
[mapView addAnnotation:addAnnotation];
[mapView setRegion:region animated:YES];
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(AddressAnnotation *) annotation
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor=MKPinAnnotationColorRed;
annView.draggable=TRUE;
annView.animatesDrop=TRUE;
annView.canShowCallout=YES;
annView.calloutOffset=CGPointMake(-5,5);
annView.draggable=TRUE;
return annView;
}
And annotation class to display the name and address.But how should i have to add more to display the route between the two points.
Please help me.
Thanks in advance
You need to invoke google’s direction services. Read the documentation at
http://code.google.com/apis/maps/documentation/directions/
Use the URL that suits your need. Then you would need a JSON or XML parser. JSON has an API, you can download it here
https://github.com/stig/json-framework/
You can then get your route polyline points using:
Also implement mapView:viewForOverlay delegate method: