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-11 10:10:51 +0200
commitdf062afe6de7ec6e4a4d3c88389bbb5279b63a06 (patch)
treeba383583c6f052d601f854cca7271f34acabfa9e
parent6262b83cc683db83aef4b3d74b29a04be53fdc3a (diff)
downloadqtlocation-mapboxgl-df062afe6de7ec6e4a4d3c88389bbb5279b63a06.tar.gz
[android] - fix reset behavior for setLatLngBoundsForCameraTarget
-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);
}