2014-01-23 63 views
-3

如何在ios地圖中顯示駕駛路線。當然,我只顯示了從出發點到目的地的路線。在Android谷歌地圖默認提供它,有沒有什麼方法在iPhone重定向到起點和目的地的iOS地圖。提前致謝。如何在ios地圖中顯示駕駛路線

+1

http://stackoverflow.com/questions/13997388/ios-driving-directions-in-ios6 – iPatel

+0

你在谷歌搜索..?? – 2014-01-23 05:08:07

+0

是的,沒有得到任何正確的方法 – user1176

回答

0

如果你不需要自定義很多如引腳和彈出。您可以將UIWebview添加到ViewController,並且隨着Google maps的webURL追加From和To位置,然後加載它。 其他 您必須添加Googlemaps,並且必須使用方法自己繪製多邊形路線。

0

給你:

CLLocationCoordinate2D coordinate = [mainHelper currentLocation].coordinate; 

MKPlacemark* placeMark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil]; 
MKMapItem* destination = [[MKMapItem alloc] initWithPlacemark:placeMark]; 
if([destination respondsToSelector:@selector(openInMapsWithLaunchOptions:)]) 
{ 
    //using iOS6 native maps app 
    if(dirType == WALK) 
    { 
     [destination openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeWalking}]; 

    } 
    if(dirType == DRIVE) 
    { 
     [destination openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving}]; 

    } 
    if(dirType == TRANSIT) 
    { 
     [destination openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving}]; 

    } 

} 
1

在iOS中7,你可以很容易地做到這一點,而不從您的應用程序傳送到用戶的地圖應用。請檢查Link並提供您的迴應。

它說

MKDirectionRequest和MKDirectionResponse

許多移動用戶依賴於從他們的設備和iOS的方向7開發者現在可以將應用的範圍內爲他們提供,而不是切換到地圖應用。您從源和目的地開始您的請求。其他選項包括備用路線,交通類型和出發/到達時間。

希望這會有所幫助。

+0

如果你同意它,你可以接受它作爲答案的解決方案 – iEinstein

相關問題