2013-10-24 149 views
-3

我有一个使用mapkit的小应用程序。我想实现导航。但我想利用已经在iPhone上的应用程序地图,给它一个起源和目的地,并告诉它显示路线。IOS映射导航

+1

你尝试什么吗? – Raptor

+0

-1因为不仅仅是问一个问题,实际上只是说明你的愿望,并没有表现出任何努力。 – borrrden

回答

2

试试这个,在viewDidLoad中

CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(42.777126,-76.113281); 
    MKPlacemark *place = [[MKPlacemark alloc]initWithCoordinate:coords addressDictionary:nil]; 
    MKMapItem *toLocation = [[MKMapItem alloc]initWithPlacemark:place]; 


    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation]; 

    [toLocation setName:@"New York"]; 
    [currentLocation setName:@"San Fransico"]; 

    [MKMapItem openMapsWithItems:[NSArray arrayWithObjects:currentLocation, toLocation, nil] 
        launchOptions:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:MKLaunchOptionsDirectionsModeDriving, [NSNumber numberWithBool:YES], nil] 
                  forKeys:[NSArray arrayWithObjects:MKLaunchOptionsDirectionsModeKey, MKLaunchOptionsShowsTrafficKey, nil]]];