Akash Patel
Akash Patel

Reputation: 2767

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

I am using android Here-sdk. I got total distance of perticular route from MapRoute object. So now i want to get arrival/travel time of perticular route.

Below is the code for distance. what would i do for get time from MapRoute object. Thanks!

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);   
} 

Upvotes: 1

Views: 1144

Answers (2)

The documentaion link change use this instead documentation

the getTTa method is deprecated now, use

Route.getTtaIncludingTraffic(int subleg)

or

Route.getTtaExcludingTraffic(int subleg)

if you want the travel time for the whole route use this value

Route.WHOLE_ROUTE

example:

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

Upvotes: 2

Piotr Tobolski
Piotr Tobolski

Reputation: 1406

You can do it like that:

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

where x is TrafficPenaltyMode and y is subleg number. You can check the details in the documentation.

Upvotes: 2

Related Questions