hi friends..
I make an application routing but I can not display the distance of the routing
how to display distance the route?
Thank you
hi friends..
I make an application routing but I can not display the distance of the routing
how to display distance the route?
Thank you
hi
do you mean you need distance calculation between two geo-points (Latitude, Longitude) or just displaying the route?
To obtain the length of a route use: Route.getSummary().getDistance(), to get an "as-the-crow-flies" distance you can use Route.getStart().getMappedPosition().distanceTo(Route.getEnd().getMappedPosition())
where I should put the code above?
this is my code
Code:public void onRequestComplete(RouteRequest request, Route[] routes) { map.removeAllMapObjects(); this.routes = routes; for (int i = 0; i < routes.length; i++) { map.addMapObject( mapFactory.createMapPolyline(routes[i].getShape(), 3)); map.setCenter(routes[i].getStart().getMappedPosition()); } progressEnd(); }
Something like this:
Code:public void onRequestComplete(RouteRequest request, Route[] routes) { map.removeAllMapObjects(); this.routes = routes; for (int i = 0; i < routes.length; i++) { map.addMapObject( mapFactory.createMapPolyline(routes[i].getShape(), 3)); map.setCenter(routes[i].getStart().getMappedPosition()); System.out.println(" THE CROW FLIES : " + routes[i].getStart().getMappedPosition().distanceTo(routes[i].getDestination().getMappedPosition())); System.out.println(" THE DRIVER GOES: " + routes[i].getSummary().getDistance()); } }