簡體   English   中英

在here-api android獲取特定路線的到達/旅行時間

[英]get arrival/travel time of perticular route in here-api android

我正在使用android Here-sdk。 我從MapRoute對象獲得了特定路徑的總距離。 所以現在我想獲得特定路線的到達/旅行時間。

以下是距離代碼。 我該怎么做才能從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);   
} 

你可以這樣做:

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

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

documentaion鏈接更改使用此代替文檔

getTTa方法現在已棄用,請使用

Route.getTtaIncludingTraffic(int subleg)

要么

Route.getTtaExcludingTraffic(int subleg)

如果您想要整個路線的旅行時間使用此值

Route.WHOLE_ROUTE

例:

int timeInSeconds = route.getTtaExcludingTraffic(Route.WHOLE_ROUTE).getDuration();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM