android-samples icon indicating copy to clipboard operation
android-samples copied to clipboard

Polyline.remove() dos not work

Open Smoke1987 opened this issue 7 years ago • 3 comments

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

Smoke1987 avatar Mar 14 '19 08:03 Smoke1987

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)

Smoke1987 avatar Mar 14 '19 08:03 Smoke1987

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

amuramoto avatar Aug 09 '19 17:08 amuramoto

mGoogleMap.clear();

Not working and getting error

Uncaught TypeError: map.clear is not a function

kamleshwebtech avatar Dec 18 '19 05:12 kamleshwebtech