summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-06-10 12:54:38 +0200
committertobrun <tobrun.van.nuland@gmail.com>2019-06-10 13:08:26 +0200
commit899df59035c440d5cc61e7ffd52cd993a1ac02f8 (patch)
treefbfeae07322697c5085d7aabff25fba440050f12
parent0bab9127d719c1ba2d6eb85096f93f600f9aa833 (diff)
downloadqtlocation-mapboxgl-upstream/tvn-bounds-reset.tar.gz
[android] - fix reset behavior for setLatLngBoundsForCameraTargetupstream/tvn-bounds-reset
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/LatLngBoundsForCameraActivity.java26
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bounds.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml1
-rwxr-xr-xplatform/android/src/native_map_view.cpp2
5 files changed, 23 insertions, 12 deletions
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 7692c1a9f2..da70013713 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 @@ interface NativeMap {
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 1a9d3d300b..2493aa00e5 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 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout;
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 class LatLngBoundsForCameraActivity extends AppCompatActivity implements
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 db7aad6d1f..4b39a392a0 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"/>
+ <item
+ android:id="@+id/menu_action_reset"
+ android:title="@string/restrict_reset"
+ app:showAsAction="never"/>
</menu>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml
index 7513baaa36..d36c741c50 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 @@
<string name="zoom_to_4">Zoom to 4</string>
<string name="restrict_almost_worldview">Restrict almost worldview</string>
<string name="restrict_across_idl">Restrict across IDL</string>
+ <string name="restrict_reset">Reset bounds</string>
</resources> \ 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 8493110d75..48b65c4c02 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::Object<mbgl::an
if (jBounds) {
bounds.withLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
} else {
- bounds.withLatLngBounds(mbgl::LatLngBounds::world());
+ bounds.withLatLngBounds(mbgl::LatLngBounds::unbounded());
}
map->setBounds(bounds);
}