0

I need to plot a route from user's current location to the destination address. Now let's say if the user takes a different route, I need to replot the route. How should I proceed?

I, obviously, will not keep on plotting the route as soon as the user's location. I need to replot only when the user takes a different route

androider
  • 982
  • 6
  • 16
  • 32

1 Answers1

0

Have already been answered here. How to draw interactive Polyline on route google maps v2 android

Code sample

PolylineOptions options = new  
            PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
for (int z = 0; z < list.size(); z++) {
   LatLng point = list.get(z);
   options.add(point);
}
line = myMap.addPolyline(options);
Community
  • 1
  • 1
Noman Rafique
  • 3,735
  • 26
  • 29
  • It will just draw the polyline. I need to redraw the path if the user takes a different route. Is there a way I can detect if user is on the drawn path or he is using a different path – androider Feb 01 '15 at 12:47
  • This feature is available in new Google Maps Navigation. I want similar feature – androider Feb 01 '15 at 14:02
  • Okay how about if your get your current location and calculate the distance between polyline and current location. If it meets a certain threshold then redraw the line from your current location to your destination. – Noman Rafique Feb 01 '15 at 14:06
  • Its not that simple what you are trying to achieve. Have a look at this link. I think thats what you are looking for. http://stackoverflow.com/questions/7803474/any-algorithm-to-find-the-shortest-path-distance-in-android/7803519#7803519 – Noman Rafique Feb 01 '15 at 14:08
  • How would I calculate distance between curent location and polyline? – androider Feb 01 '15 at 14:10
  • Read my last comment. – Noman Rafique Feb 01 '15 at 14:15