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
Printable View
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: [B]Route.getSummary().getDistance()[/B], to get an "as-the-crow-flies" distance you can use [B]Route.getStart().getMappedPosition().distanceTo(Route.getEnd().getMappedPosition())[/B]
[QUOTE=izinin;896893]hi
do you mean you need distance calculation between two geo-points (Latitude, Longitude) or just displaying the route?[/QUOTE]
I need distance calculation between two geo-points
[QUOTE=jasfox;896909]To obtain the length of a route use: [B]Route.getSummary().getDistance()[/B], to get an "as-the-crow-flies" distance you can use [B]Route.getStart().getMappedPosition().distanceTo(Route.getEnd().getMappedPosition())[/B][/QUOTE]
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();
}
[/CODE]
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());
}
}[/CODE]