1

Basically, what I simply need to achieve is, first draw the route between two points, from current location to any other point on the map. And when a third point is place, the route must change from current to third point and finally from third point to final point.

For reference,

Point A - Current/Start Location

Point B - End Location

Point C - Third Location

Tasks

1) Draw point from A to B

2) If C point is placed, draw from A to C and C to B.

How can I implement this ?

Thank you

2 Answers2

1

you can use way points. When calculating routes using the Google Maps Directions API, you may also specify waypoints for driving, walking or bicycling directions. Waypoints are not available for transit directions. You can use waypoints to calculate routes through additional locations, in which case the returned route includes stopovers at each of the given waypoints.

For more details visit here

Sample url will be like follows

https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&key=YOUR_API_KEY
Vinayak B
  • 4,430
  • 4
  • 28
  • 58
1

This should work.

private void displayDirection(List<LatLng> poly){
        PolylineOptions polylineOptions= new PolylineOptions();
                polylineOptions.color(Color.RED);
            for(int i=0; i<poly.size(); i++){
                polylineOptions.width(8);
                polylineOptions.add(poly.get(i));
            }
        mMap.addPolyline(polylineOptions);
        }