Mkmapview中如何根据路线绘制Polyline

How to draw Polyline based on route in Mkmapview

大家好,我需要在 MKapview 中显示 Polyline。我已经做到了,但我需要根据路线显示 Polyline。如果我使用的位置确实更新了,那么我会像下图那样好,我会尝试存储纬度和经度,然后下次我必须显示以前的 Polyline 时我没有得到,请帮助我

- (void)drowRoautLines_FromLocation:(CLLocationCoordinate2D)FromLocation ToLocation:(CLLocationCoordinate2D)ToLocation
{
    MKPlacemark *source = [[MKPlacemark alloc]initWithCoordinate:FromLocation
                                               addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil]];
    MKMapItem *srcMapItem = [[MKMapItem alloc]initWithPlacemark:source];
    [srcMapItem setName:@"Source"];

    MKPlacemark *destination = [[MKPlacemark alloc]initWithCoordinate:ToLocation
                                                    addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil]];
    MKMapItem *distMapItem = [[MKMapItem alloc]initWithPlacemark:destination];
    [distMapItem setName:@"Destination"];

    MKDirectionsRequest *request = [[MKDirectionsRequest alloc]init];
    [request setSource:srcMapItem];
    [request setDestination:distMapItem];
    [request setTransportType:MKDirectionsTransportTypeAutomobile];

    MKDirections *direction = [[MKDirections alloc]initWithRequest:request];

    [direction calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error)
    {
        [self ShowLoading:NO];

        NSLog(@"response = %@",response);
        NSLog(@"error = %@",error);
        NSArray *arrRoutes = [response routes];
        if (arrRoutes.count == 0)
        {
            //Show Error Message.
        }
        else
        {
            [arrRoutes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
            {

                MKRoute *rout = obj;
                MKPolyline *line = [rout polyline];
                [mapView addOverlay:line];

                NSLog(@"Rout Name : %@",rout.name);
                NSLog(@"Total Distance (in Meters) :%f",rout.distance);
                NSArray *steps = [rout steps];
                NSLog(@"Total Steps : %lu",(unsigned long)[steps count]);

                [steps enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
                {
                    //NSLog(@"Rout Instruction : %@",[obj instructions]);
                }];
            }];
        }
    }];

}