diff options
author | Erlend Fagerheim <erlendf80@gmail.com> | 2015-08-16 11:48:46 +0200 |
---|---|---|
committer | Erlend Fagerheim <erlendf80@gmail.com> | 2015-08-16 11:48:46 +0200 |
commit | 63710ffdac09dc00e034ba775cb68929d487a6b6 (patch) | |
tree | 408f7f5b685e1f6191b7de58e33016735c6e081b /android | |
parent | 20ad0d51f6e6d82587e2beac34f390356409e152 (diff) | |
download | qtlocation-mapboxgl-63710ffdac09dc00e034ba775cb68929d487a6b6.tar.gz |
removing annotations in mapview, not only in nativemapview
Diffstat (limited to 'android')
-rw-r--r-- | android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java index 20e7dfe56a..d1ed8923d9 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java @@ -59,6 +59,7 @@ import org.apache.commons.validator.routines.UrlValidator; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Date; +import java.util.Iterator; import java.util.List; // Custom view that shows a Map @@ -371,13 +372,24 @@ public class MapView extends FrameLayout implements LocationListener { return polygons; } + private void removeAnnotationsWithId(long annotationId){ + for (Iterator<Annotation> iterator = annotations.iterator(); iterator.hasNext();) { + Annotation annotation = iterator.next(); + if (annotation.getId() == annotationId) { + iterator.remove(); + } + } + } + public void removeAnnotation(Annotation annotation) { long id = annotation.getId(); mNativeMapView.removeAnnotation(id); + annotations.remove(annotation); } public void removeAnnotation(long annotationId) { mNativeMapView.removeAnnotation(annotationId); + removeAnnotationsWithId(annotationId); } public void removeAnnotations() { @@ -387,6 +399,7 @@ public class MapView extends FrameLayout implements LocationListener { ids[i] = id; } mNativeMapView.removeAnnotations(ids); + annotations.clear(); } // |