[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:
Ander Conselvan de Oliveira
2019-03-08 12:43:05 +02:00
parent 11de777628
commit 5733440747
11 changed files with 126 additions and 59 deletions

View File

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