diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java index 7692c1a9f2b..da70013713d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java @@ -63,7 +63,7 @@ void easeTo(@NonNull LatLng center, double zoom, double bearing, double pitch, l LatLng getLatLng(); - void setLatLngBounds(@NonNull LatLngBounds latLngBounds); + void setLatLngBounds(@Nullable LatLngBounds latLngBounds); void setVisibleCoordinateBounds(@NonNull LatLng[] coordinates, @NonNull RectF padding, double direction, long duration); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/LatLngBoundsForCameraActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/LatLngBoundsForCameraActivity.java index 1a9d3d300be..2493aa00e50 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/LatLngBoundsForCameraActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/LatLngBoundsForCameraActivity.java @@ -3,6 +3,7 @@ import android.graphics.Color; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.view.Gravity; import android.view.Menu; @@ -76,25 +77,30 @@ public boolean onOptionsItemSelected(MenuItem item) { case R.id.menu_action_cross_idl: setupBounds(CROSS_IDL_BOUNDS); return true; + case R.id.menu_action_reset: + setupBounds(null); + return true; } return super.onOptionsItemSelected(item); } - private void setupBounds(LatLngBounds bounds) { + private void setupBounds(@Nullable LatLngBounds bounds) { mapboxMap.setLatLngBoundsForCameraTarget(bounds); showBoundsArea(bounds); } - private void showBoundsArea(LatLngBounds bounds) { + private void showBoundsArea(@Nullable LatLngBounds bounds) { mapboxMap.clear(); - PolygonOptions boundsArea = new PolygonOptions() - .add(bounds.getNorthWest()) - .add(bounds.getNorthEast()) - .add(bounds.getSouthEast()) - .add(bounds.getSouthWest()); - boundsArea.alpha(0.25f); - boundsArea.fillColor(Color.RED); - mapboxMap.addPolygon(boundsArea); + if (bounds != null) { + PolygonOptions boundsArea = new PolygonOptions() + .add(bounds.getNorthWest()) + .add(bounds.getNorthEast()) + .add(bounds.getSouthEast()) + .add(bounds.getSouthWest()); + boundsArea.alpha(0.25f); + boundsArea.fillColor(Color.RED); + mapboxMap.addPolygon(boundsArea); + } } private void showCrosshair() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bounds.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bounds.xml index db7aad6d1f2..4b39a392a0e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bounds.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bounds.xml @@ -9,4 +9,8 @@ android:id="@+id/menu_action_cross_idl" android:title="@string/restrict_across_idl" app:showAsAction="never"/> + diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml index 7513baaa368..d36c741c508 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml @@ -90,4 +90,5 @@ Zoom to 4 Restrict almost worldview Restrict across IDL + Reset bounds \ No newline at end of file diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 8493110d756..48b65c4c025 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -314,7 +314,7 @@ void NativeMapView::setLatLngBounds(jni::JNIEnv& env, const jni::ObjectsetBounds(bounds); }