Reputation: 2767
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
Reputation: 23
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
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