0

Reference to this thread mentioned below. How to check if my current location is on the route that i draw befor, and if not, redraw route

I am unable to find any proper solution. If user(Current-location) don't follow the route that I draw before, So it should redraw the route between points A and B.

Community
  • 1
  • 1

1 Answers1

1

You can use the PolyUtil.isLocationOnPath from the Google Maps Android API Utility Library.

From the documentation:

isLocationOnPath

public static boolean isLocationOnPath(LatLng point, java.util.List polyline, boolean geodesic, double tolerance)

Computes whether the given point lies on or near a polyline, within a specified tolerance in meters. The polyline is composed of great circle segments if geodesic is true, and of Rhumb segments otherwise. The polyline is not closed -- the closing segment between the first point and the last point is not included.

antonio
  • 18,044
  • 4
  • 45
  • 61
  • What will be the last 2 params? – Ahsan Khan Jan 09 '17 at 14:51
  • Last param, the tolerance means how far can be the point to be considered out of the route. The geodesic param means whether the earth must be considered round or can be approached by a flat surface (if the route is "small", about a hundred kilometers, it can be false, otherwise it must be true) – antonio Jan 09 '17 at 14:54
  • @antonio thank you for the solution , am having another doubt how to remove the polyline behind the marker as the marker move frequently how to do this antonio – M.Yogeshwaran Sep 11 '18 at 06:14