Optimized RemoveAnnotations to a single call

This commit is contained in:
Niklas Ulvinge
2015-07-19 19:59:46 +02:00
parent 13d86d4cbc
commit ab82bdd438
5 changed files with 47 additions and 14 deletions

View File

@@ -23,7 +23,7 @@ public abstract class Annotation {
return alpha;
}
public long getId() {
public Long getId() {
return id;
}

View File

@@ -49,17 +49,6 @@ public class Marker extends Annotation {
return anchorV;
}
/**
* NOTE: Google Maps Android API uses String for IDs.
*
* Internal C++ id is stored as unsigned int.
*
* @return the annotation id
*/
public long getId() {
return id;
}
public LatLng getPosition() {
return position;
}

View File

@@ -270,9 +270,16 @@ public class MapView extends SurfaceView {
}
public void removeAnnotations() {
for (Annotation annotation : annotations) {
annotation.remove();
long[] ids = new long[annotations.size()];
for(int i=0; i<annotations.size(); i++) {
Long id = annotations.get(i).getId();
if(id == null) {
ids[i] = -1;
} else {
ids[i] = id;
}
}
mNativeMapView.removeAnnotations(ids);
}
//

View File

@@ -239,6 +239,10 @@ class NativeMapView {
nativeRemoveAnnotation(mNativeMapViewPtr, id);
}
public void removeAnnotations(long[] ids) {
nativeRemoveAnnotations(mNativeMapViewPtr, ids);
}
public LatLng getLatLng() {
return nativeGetLatLng(mNativeMapViewPtr);
}
@@ -481,6 +485,8 @@ class NativeMapView {
private native void nativeRemoveAnnotation(long nativeMapViewPtr, long id);
private native void nativeRemoveAnnotations(long nativeMapViewPtr, long[] id);
private native LatLng nativeGetLatLng(long nativeMapViewPtr);
private native void nativeResetPosition(long nativeMapViewPtr);