[core] Group Map LatLngBounds, min and max zoom methods
Group bounds, minimum and maximum zoom related methods together using the new BoundOptions. v2: Document that getBounds() initializes all optional fields. - Add test for getBounds() on a map with default values.
This commit is contained in:
@@ -287,11 +287,13 @@ void NativeMapView::setStyleJson(jni::JNIEnv& env, const jni::String& json) {
|
||||
}
|
||||
|
||||
void NativeMapView::setLatLngBounds(jni::JNIEnv& env, const jni::Object<mbgl::android::LatLngBounds>& jBounds) {
|
||||
mbgl::BoundOptions bounds;
|
||||
if (jBounds) {
|
||||
map->setLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
|
||||
bounds.withLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
|
||||
} else {
|
||||
map->setLatLngBounds(mbgl::LatLngBounds::world());
|
||||
bounds.withLatLngBounds(mbgl::LatLngBounds::world());
|
||||
}
|
||||
map->setBounds(bounds);
|
||||
}
|
||||
|
||||
void NativeMapView::cancelTransitions(jni::JNIEnv&) {
|
||||
@@ -424,19 +426,19 @@ void NativeMapView::resetZoom(jni::JNIEnv&) {
|
||||
}
|
||||
|
||||
void NativeMapView::setMinZoom(jni::JNIEnv&, jni::jdouble zoom) {
|
||||
map->setMinZoom(zoom);
|
||||
map->setBounds(BoundOptions().withMinZoom(zoom));
|
||||
}
|
||||
|
||||
jni::jdouble NativeMapView::getMinZoom(jni::JNIEnv&) {
|
||||
return map->getMinZoom();
|
||||
return *map->getBounds().minZoom;
|
||||
}
|
||||
|
||||
void NativeMapView::setMaxZoom(jni::JNIEnv&, jni::jdouble zoom) {
|
||||
map->setMaxZoom(zoom);
|
||||
map->setBounds(BoundOptions().withMaxZoom(zoom));
|
||||
}
|
||||
|
||||
jni::jdouble NativeMapView::getMaxZoom(jni::JNIEnv&) {
|
||||
return map->getMaxZoom();
|
||||
return *map->getBounds().maxZoom;
|
||||
}
|
||||
|
||||
void NativeMapView::rotateBy(jni::JNIEnv&, jni::jdouble sx, jni::jdouble sy, jni::jdouble ex, jni::jdouble ey, jni::jlong duration) {
|
||||
|
||||
Reference in New Issue
Block a user