2013-10-24 90 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]]];