I am getting the latitude and longitude on every onLocationChange and make a route like this:
public void onLocationChanged(Location location) {
PolylineOptions rectLine2;
rectLine2.add(new LatLng(lat, lon));
mGoogleMap.addPolyline(rectLine2);
}
Now I want to clear this route on one click, and again when I move, a fresh route should draw, but in my case, old route doesn't clear.
I did the following but not working:
mGoogleMap.clear();// It clear's the map, but when I again draw the old route again comes.
Also
Polyline polyline;
polyline = mGoogleMap.addPolyline(rectLine2);
polyline.reomve()// This also didn't work.
Is there any other solution to clear the map?
Thanks In Advance!