summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2015-08-17 13:46:46 +1000
committerLeith Bade <leith@mapbox.com>2015-08-17 13:46:46 +1000
commit1e14057b0d938f178a595f08dd82b4645d0bd833 (patch)
tree408f7f5b685e1f6191b7de58e33016735c6e081b
parent20ad0d51f6e6d82587e2beac34f390356409e152 (diff)
parent63710ffdac09dc00e034ba775cb68929d487a6b6 (diff)
downloadqtlocation-mapboxgl-1e14057b0d938f178a595f08dd82b4645d0bd833.tar.gz
Merge pull request #2089 from erf/remove-annotations-in-mapview
removing annotations in mapview, not only in nativemapview
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java13
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();
}
//