Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在Mkmapview中基于管线绘制多段线_Objective C_Mkmapview_Core Location_Polyline - Fatal编程技术网

Objective c 如何在Mkmapview中基于管线绘制多段线

Objective c 如何在Mkmapview中基于管线绘制多段线,objective-c,mkmapview,core-location,polyline,Objective C,Mkmapview,Core Location,Polyline,您好,我需要在MKapview中显示多段线。我已经这样做了,但我需要基于路线显示多段线。我得到下面的图片如果我使用的位置确实更新了,那么它很好,我尝试存储纬度和经度,然后下次我必须显示以前的多段线,在这段时间我没有得到,请帮助我 - (void)drowRoautLines_FromLocation:(CLLocationCoordinate2D)FromLocation ToLocation:(CLLocationCoordinate2D)ToLocation { MKPlacema

您好,我需要在
MKapview
中显示
多段线
。我已经这样做了,但我需要基于路线显示
多段线。我得到下面的图片如果我使用的位置确实更新了,那么它很好,我尝试存储纬度和经度,然后下次我必须显示以前的
多段线
,在这段时间我没有得到,请帮助我

- (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]);
                }];
            }];
        }
    }];

}