Polyline.remove() dos not work
When I add a line to the map and then delete it (as indicated in documentation) the line remains on the map.
ArrayList<LatLng> firstRoute = google_roads.get(0);
PolylineOptions routeOptions = new PolylineOptions();
for (int i = 0; i < firstRoute.size(); i++) {
routeOptions.add(firstRoute.get(i));
}
// Get back the mutable Polyline
mRoadPolyline = mGoogleMap.addPolyline(routeOptions);
....
// try to remove line - line still on the map
if (mRoadPolyline != null) {
mRoadPolyline.remove();
//mRoadPolyline = null;
//mRoadPolylineOptions = null;
Log.d(TAG, "clearRouteForGoogleMaps() -> remove()");
}
Android info: compileSdkVersion 26 buildToolsVersion '26.0.2' minSdkVersion 16 targetSdkVersion 26 (run on Android 4.4.2)
Package info: com.google.android.gms:play-services-maps:11.0.2
If I clear the whole map,
mGoogleMap.clear();
the line disappears, and, respectively, the markers. I really do not want to use crutches in the application (clear the entire map -> re-draw markers)
This would be a bug with the SDK rather than this util lib. Please open a bug in the issue tracker:
https://issuetracker.google.com/savedsearches/5446940
mGoogleMap.clear();
Not working and getting error
Uncaught TypeError: map.clear is not a function