2016-10-17 17 views
1

我正在使用android here-sdk。我從MapRoute對象得到了總體關於路線的距離。所以,現在我想要得到關鍵路線的到達/旅行時間。得到pertial路線的到達/旅行時間在這裏 - api android

以下是距離代碼。我會怎樣做才能從MapRoute獲得時間對象。謝謝!

for(int i = list_routes.size() ; i > 0 ; i--) 
{ 
    MapRoute mapRoute = new MapRoute(list_routes.get(i-1).getRoute()); 
    mapRoute.setColor(color_array.get(i-1)); 
    mapRoute.setTrafficEnabled(true); 

    // here i got total distance 
    int distance = mapRoute.getRoute().getLength(); 

    m_map.addMapObject(mapRoute); 
} 

回答

2

你可以那樣做:

int timeInSeconds = mapRoute.getRoute().getTta(x, y).getDuration(); 

其中xTrafficPenaltyModey是subleg數。您可以查看documentation中的詳細信息。

+0

如果我將'mapRoute.getRoute()。getSublegCount()'作爲'y'值傳遞給** IllegalArgumentException的異常:subleg必須大於等於0且小於subleg的個數* * –

+0

錯誤告訴了這一切。只要看看你在做什麼。 – greenapps

+1

@Akash請閱讀文檔。有一個特殊值'WHOLE_ROUTE',你可以通過它來計算整個路徑的tta。 – Tobol

相關問題