summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java54
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java12
-rwxr-xr-xplatform/android/src/jni.cpp16
4 files changed, 83 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31c853a1b7..45eedeb6f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
* Fixed crash caused by annotation image with non-integer width or height ([#3031](https://github.com/mapbox/mapbox-gl-native/issues/3031))
* Tracking Mode Reverses Bearing Fix ([#3664](https://github.com/mapbox/mapbox-gl-native/issues/3664))
* GPS Extra Rotation Fix ([#3661](https://github.com/mapbox/mapbox-gl-native/issues/3661))
+* Added new methods for getting and setting the min and max zoom levels: `getMinZoom`, `setMinZoom`, `getMaxZoom`, `setMaxZoom`. ([#509](https://github.com/mapbox/mapbox-gl-native/issues/509))
## 3.1.0
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
index 53667efadf..b4ae086515 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
@@ -1671,6 +1671,60 @@ public final class MapView extends FrameLayout {
}
/**
+ * <p>
+ * Sets the minimum zoom level the map can be displayed at.
+ * </p>
+ *
+ * @param minZoom The new minimum zoom level.
+ */
+ @UiThread
+ public void setMinZoom(@FloatRange(from = 0.0, to = 25.0) double minZoom) {
+ if ((minZoom < 0.0) || (minZoom > 25.0)) {
+ throw new IllegalArgumentException("zoomLevel is < 0 or > 25");
+ }
+ mNativeMapView.setMinZoom(minZoom);
+ }
+
+ /**
+ * <p>
+ * Gets the maximum zoom level the map can be displayed at.
+ * </p>
+ *
+ * @return The minimum zoom level.
+ */
+ @UiThread
+ public double getMinZoom() {
+ return mNativeMapView.getMinZoom();
+ }
+
+ /**
+ * <p>
+ * Sets the maximum zoom level the map can be displayed at.
+ * </p>
+ *
+ * @param maxZoom The new maximum zoom level.
+ */
+ @UiThread
+ public void setMaxZoom(@FloatRange(from = 0.0, to = 25.0) double maxZoom) {
+ if ((maxZoom < 0.0) || (maxZoom > 25.0)) {
+ throw new IllegalArgumentException("zoomLevel is < 0 or > 25");
+ }
+ mNativeMapView.setMaxZoom(maxZoom);
+ }
+
+ /**
+ * <p>
+ * Gets the maximum zoom level the map can be displayed at.
+ * </p>
+ *
+ * @return The maximum zoom level.
+ */
+ @UiThread
+ public double getMaxZoom() {
+ return mNativeMapView.getMaxZoom();
+ }
+
+ /**
* Returns whether the user may zoom the map.
*
* @return If true, zooming is enabled.
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java
index 2d9d1ebb2d..2ca34de088 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/NativeMapView.java
@@ -319,10 +319,18 @@ final class NativeMapView {
nativeResetZoom(mNativeMapViewPtr);
}
+ public void setMinZoom(double zoom) {
+ nativeSetMinZoom(mNativeMapViewPtr, zoom);
+ }
+
public double getMinZoom() {
return nativeGetMinZoom(mNativeMapViewPtr);
}
+ public void setMaxZoom(double zoom) {
+ nativeSetMaxZoom(mNativeMapViewPtr, zoom);
+ }
+
public double getMaxZoom() {
return nativeGetMaxZoom(mNativeMapViewPtr);
}
@@ -588,8 +596,12 @@ final class NativeMapView {
private native void nativeResetZoom(long nativeMapViewPtr);
+ private native void nativeSetMinZoom(long nativeMapViewPtr, double zoom);
+
private native double nativeGetMinZoom(long nativeMapViewPtr);
+ private native void nativeSetMaxZoom(long nativeMapViewPtr, double zoom);
+
private native double nativeGetMaxZoom(long nativeMapViewPtr);
private native void nativeRotateBy(long nativeMapViewPtr, double sx,
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index e59f67cc19..1657456215 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -777,6 +777,13 @@ void JNICALL nativeResetZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
nativeMapView->getMap().resetZoom();
}
+void JNICALL nativeSetMinZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble zoom) {
+ mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetMinZoom");
+ assert(nativeMapViewPtr != 0);
+ NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
+ nativeMapView->getMap().setMinZoom(zoom);
+}
+
jdouble JNICALL nativeGetMinZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetMinZoom");
assert(nativeMapViewPtr != 0);
@@ -784,6 +791,13 @@ jdouble JNICALL nativeGetMinZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPt
return nativeMapView->getMap().getMinZoom();
}
+void JNICALL nativeSetMaxZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble zoom) {
+ mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetMaxZoom");
+ assert(nativeMapViewPtr != 0);
+ NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
+ nativeMapView->getMap().setMaxZoom(zoom);
+}
+
jdouble JNICALL nativeGetMaxZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetMaxZoom");
assert(nativeMapViewPtr != 0);
@@ -2087,7 +2101,9 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
reinterpret_cast<void *>(&nativeGetLatLngZoom)},
{"nativeResetZoom", "(J)V", reinterpret_cast<void *>(&nativeResetZoom)},
{"nativeGetMinZoom", "(J)D", reinterpret_cast<void *>(&nativeGetMinZoom)},
+ {"nativeSetMinZoom", "(JD)V", reinterpret_cast<void *>(&nativeSetMinZoom)},
{"nativeGetMaxZoom", "(J)D", reinterpret_cast<void *>(&nativeGetMaxZoom)},
+ {"nativeSetMaxZoom", "(JD)V", reinterpret_cast<void *>(&nativeSetMaxZoom)},
{"nativeRotateBy", "(JDDDDJ)V", reinterpret_cast<void *>(&nativeRotateBy)},
{"nativeSetBearing", "(JDJ)V",
reinterpret_cast<void *>(