[android] #4335 - add clear method for removing annotations to MapboxMap

This commit is contained in:
Tobrun
2016-04-08 10:03:21 +02:00
parent 7fa32a0d08
commit ef65d2015c
3 changed files with 21 additions and 1 deletions

View File

@@ -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.
*

View File

@@ -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:

View File

@@ -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<>();