[android] #4335 - add clear method for removing annotations to MapboxMap
This commit is contained in:
@@ -894,6 +894,14 @@ public class MapboxMap {
|
||||
mAnnotations.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all markers, polylines, polygons, overlays, etc from the map.
|
||||
*/
|
||||
@UiThread
|
||||
public void clear(){
|
||||
removeAnnotations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a annotation based on its id.
|
||||
*
|
||||
|
||||
@@ -159,7 +159,7 @@ public class PolylineActivity extends AppCompatActivity {
|
||||
case R.id.action_id_remove:
|
||||
// test to remove all annotations
|
||||
mPolylineOptions.clear();
|
||||
mMapboxMap.removeAnnotations();
|
||||
mMapboxMap.clear();
|
||||
return true;
|
||||
|
||||
case android.R.id.home:
|
||||
|
||||
@@ -751,6 +751,18 @@ public class MapboxMapTest {
|
||||
assertTrue("Annotations should be empty", mMapboxMap.getAnnotations().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClear() {
|
||||
List<MarkerOptions> markerList = new ArrayList<>();
|
||||
MarkerOptions markerOptions1 = new MarkerOptions().title("a");
|
||||
MarkerOptions markerOptions2 = new MarkerOptions().title("b");
|
||||
markerList.add(markerOptions1);
|
||||
markerList.add(markerOptions2);
|
||||
mMapboxMap.addMarkers(markerList);
|
||||
mMapboxMap.clear();
|
||||
assertTrue("Annotations should be empty", mMapboxMap.getAnnotations().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveAnnotationsByList() {
|
||||
List<MarkerOptions> markerList = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user