This is how I draw a polyline :
List<LatLng> latLngsList = new ArrayList<>();
for (LegsItem leg : response.body().getRoutes().get(0).getLegs()) {
for (StepsItem step : leg.getSteps()) {
List<LatLng> latLngs = PolyUtil.decode(step.getGeometry());
step.setLatLngs(latLngs);
latLngsList.addAll(latLngs);
}
}
Polyline polyline1 = googleMap.addPolyline(new PolylineOptions()
.addAll(latLngsList));
I draw this on color black but when I am on the polyline(In LatLtg), I want to change the color to blue. To detect if I am on the point, I use the below:
mMap.setOnMyLocationChangeListener
and check if the first not done point is near than 2 m :
double dis = currentLocation.distanceTo(location);
But it does not work correctly