toggle removes all annotations. ready for polygon JNI #1716
This commit is contained in:
@@ -32,6 +32,8 @@ import com.almeros.android.multitouch.gesturedetectors.TwoFingerGestureDetector;
|
||||
import com.mapbox.mapboxgl.annotations.Annotation;
|
||||
import com.mapbox.mapboxgl.annotations.Marker;
|
||||
import com.mapbox.mapboxgl.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxgl.annotations.Polygon;
|
||||
import com.mapbox.mapboxgl.annotations.PolygonOptions;
|
||||
import com.mapbox.mapboxgl.annotations.Polyline;
|
||||
import com.mapbox.mapboxgl.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
@@ -232,11 +234,29 @@ public class MapView extends SurfaceView {
|
||||
return polyline;
|
||||
}
|
||||
|
||||
public Polygon addPolygon(PolygonOptions polygonOptions) {
|
||||
Polygon polygon = polygonOptions.getPolygon();
|
||||
Long id = mNativeMapView.addPolygon(polygon);
|
||||
polygon.setId(id);
|
||||
polygon.setMapView(this);
|
||||
annotations.add(polygon);
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public void removeAnnotation(Annotation annotation) {
|
||||
long id = annotation.getId();
|
||||
mNativeMapView.removeAnnotation(id);
|
||||
}
|
||||
|
||||
public void removeAnnotation(long annotationId) {
|
||||
mNativeMapView.removeAnnotation(annotationId);
|
||||
}
|
||||
|
||||
public void removeAnnotations() {
|
||||
for (Annotation annotation : annotations) {
|
||||
annotation.remove();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Property methods
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.graphics.PointF;
|
||||
import android.view.Surface;
|
||||
|
||||
import com.mapbox.mapboxgl.annotations.Marker;
|
||||
import com.mapbox.mapboxgl.annotations.Polygon;
|
||||
import com.mapbox.mapboxgl.annotations.Polyline;
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.geometry.LatLngZoom;
|
||||
@@ -225,6 +226,11 @@ class NativeMapView {
|
||||
return nativeAddPolyline(mNativeMapViewPtr, polyline);
|
||||
}
|
||||
|
||||
public long addPolygon(Polygon polygon) {
|
||||
// NH TODO Throw exception if returns -1
|
||||
return nativeAddPolygon(mNativeMapViewPtr, polygon);
|
||||
}
|
||||
|
||||
public void removeAnnotation(long id) {
|
||||
nativeRemoveAnnotation(mNativeMapViewPtr, id);
|
||||
}
|
||||
@@ -465,6 +471,8 @@ class NativeMapView {
|
||||
|
||||
private native long nativeAddPolyline(long nativeMapViewPtr, Polyline polyline);
|
||||
|
||||
private native long nativeAddPolygon(long mNativeMapViewPtr, Polygon polygon);
|
||||
|
||||
private native void nativeRemoveAnnotation(long nativeMapViewPtr, long id);
|
||||
|
||||
private native LatLng nativeGetLatLng(long nativeMapViewPtr);
|
||||
|
||||
Reference in New Issue
Block a user