How can I get the nearest point from my location in a polyline? I have used the below code to do my job
but it gives me output something like this:
List<LatLng> points = new ArrayList<>();
points.add(new LatLng(2, 2));
points.add(new LatLng(4, 2));
points.add(new LatLng(4, 4));
points.add(new LatLng(2, 4));
points.add(new LatLng(2, 2));
LatLng testPoint = new LatLng(3, 0);
LatLng nearestPoint = findNearestPoint(testPoint, points);
Log.e("NEAREST POINT: ", "" + nearestPoint); // lat/lng: (3.0,2.0)
But I want the index of the polyline (ArrayList containing a list of Polyline) which is closest to the given point, I have tried many methods but none of them worked out.
Please let me know if you got the solution.