[android] getters, setters for minZoom, maxZoom

adds:
map.getMminZoom();
map.setMminZoom(double);
map.getMaxZoom();
map.setMaxZoom(double);
This commit is contained in:
Ansis Brammanis
2016-01-27 11:01:38 -08:00
parent 1644234179
commit ca0099b6a4
4 changed files with 83 additions and 0 deletions

View File

@@ -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

View File

@@ -1670,6 +1670,60 @@ public final class MapView extends FrameLayout {
mNativeMapView.setZoom(zoomLevel, duration);
}
/**
* <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.
*

View File

@@ -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,

View File

@@ -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 *>(