I want to show the driving route between two locations in my android app. I want to draw the route only on top of road segments.
There are several answers on stack o
You can use this library, and it's simple, check example of usage:
Routing routing = new Routing.Builder()
.travelMode(AbstractRouting.TravelMode.DRIVING)
.withListener(this)
.alternativeRoutes(true)
.waypoints(start, end)
.build();
routing.execute();
@Override
public void onRoutingSuccess(List route, int shortestRouteIndex) {
progressDialog.dismiss();
CameraUpdate center = CameraUpdateFactory.newLatLng(start);
CameraUpdate zoom = CameraUpdateFactory.zoomTo(16);
map.moveCamera(center);
if(polylines.size()>0) {
for (Polyline poly : polylines) {
poly.remove();
}
}
polylines = new ArrayList<>();
// Add route(s) to the map.
for (int i = 0; i
And don't forget to add key
using builder from example, if you getting warnings about keyless access (you should have billing account to use it with key)