You can add solid line(Path) by adding this simple method in your code:
-(void)addSolidLine:(CLLocation *)source andDestination:(CLLocation*)destination
{
CLLocationCoordinate2D coordinates[2] = {source.coordinate, destination.coordinate};
MKGeodesicPolyline *geodesicPolylineSolid = [MKGeodesicPolyline polylineWithCoordinates:coordinates count:2];
[self.mapView addOverlay:geodesicPolylineSolid];
}
#pragma mark - map view delegate
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKPolyline class]]) {
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithPolyline:(MKPolyline *)overlay];
renderer.lineWidth = 1.5f;
renderer.strokeColor = [UIColor greenColor];
renderer.alpha = 50;
return renderer;
}
}
And if you want to show dotted line, you can just add this medthod:
MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithPolyline:(MKPolyline *)overlay];
renderer.lineDashPattern = @[@2, @5];
renderer.lineWidth = 1.5f;
renderer.strokeColor = [UIColor redColor];
renderer.alpha = 50;
isShowingDottedLine = false;
return renderer;