i am making an navigation based application. In this application i am drawing a route from points selected by the user.
for Calculating the route i have used Google direction API
. and for drawing the route i have used this code
- (void) drawRoute:(NSArray *) path
{
NSInteger numberOfSteps = path.count;
[self.objMapView removeOverlays: self.objMapView.overlays];
CLLocationCoordinate2D coordinates[numberOfSteps];
for (NSInteger index = 0; index < numberOfSteps; index++)
{
CLLocation *location = [path objectAtIndex:index];
CLLocationCoordinate2D coordinate = location.coordinate;
coordinates[index] = coordinate;
}
for( id <MKOverlay> ovr in [self.objMapView overlays])
{
MKPolylineView *polylineView = [[MKPolylineView alloc] initWithPolyline:ovr];
if (polylineView.tag == 22)
{
[self.objMapView removeOverlay:ovr];
}
[polylineView release];
}
MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:coordinates count:numberOfSteps];
[self.objMapView addOverlay:polyLine];
}
PROBLEM :~ When i am drawing a route i encountered a problem that it is not drawing polyline on the road. To explain this i have attached an image
as shown in the picture polyline is not on the road.
I have used UICGDirections
but it is not working properly some times.
Please help me i am new to mapview.
Thanks in advance