Add multiple polygons at once to increase performance
This commit is contained in:
@@ -243,6 +243,23 @@ public class MapView extends SurfaceView {
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public List<Polygon> addPolygons(List<PolygonOptions> polygonOptions) {
|
||||
List<Polygon> polygons = new ArrayList<>();
|
||||
for(PolygonOptions popts : polygonOptions) {
|
||||
polygons.add(popts.getPolygon());
|
||||
}
|
||||
|
||||
long[] ids = mNativeMapView.addPolygons(polygons);
|
||||
|
||||
for(int i=0; i<polygons.size(); i++) {
|
||||
polygons.get(i).setId(ids[i]);
|
||||
polygons.get(i).setMapView(this);
|
||||
annotations.add(polygons.get(i));
|
||||
}
|
||||
|
||||
return polygons;
|
||||
}
|
||||
|
||||
public void removeAnnotation(Annotation annotation) {
|
||||
long id = annotation.getId();
|
||||
mNativeMapView.removeAnnotation(id);
|
||||
|
||||
@@ -230,6 +230,11 @@ class NativeMapView {
|
||||
return nativeAddPolygon(mNativeMapViewPtr, polygon);
|
||||
}
|
||||
|
||||
public long[] addPolygons(List<Polygon> polygon) {
|
||||
// NH TODO Throw exception if returns -1
|
||||
return nativeAddPolygons(mNativeMapViewPtr, polygon);
|
||||
}
|
||||
|
||||
public void removeAnnotation(long id) {
|
||||
nativeRemoveAnnotation(mNativeMapViewPtr, id);
|
||||
}
|
||||
@@ -472,6 +477,8 @@ class NativeMapView {
|
||||
|
||||
private native long nativeAddPolygon(long mNativeMapViewPtr, Polygon polygon);
|
||||
|
||||
private native long[] nativeAddPolygons(long mNativeMapViewPtr, List<Polygon> polygon);
|
||||
|
||||
private native void nativeRemoveAnnotation(long nativeMapViewPtr, long id);
|
||||
|
||||
private native LatLng nativeGetLatLng(long nativeMapViewPtr);
|
||||
|
||||
Reference in New Issue
Block a user