java – Google map android sdk optimal route between many points


I am making an android application there comes an array of objects (10-30 pieces) on the Google map and you need to display them on the map and build an optimal route between these objects. Previously, I did not work much with Google map and I just can't find an example or a description of how to do it.


I think in order to create an optimal route with n points, you need to build a route in pairs between them. To build a route between two points on the map, you need to call the google api method to build a route between two points.

"" + parameters;

Where parameters is a string that is rendered like this

String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
String parameters = str_origin + "&" + str_dest + "&sensor=false;

In response, you will receive an array of points. You simply connect these points to each other in googleMaps using the map method

Scroll to Top