[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:
@@ -85,7 +85,7 @@ TEST(Annotations, LineAnnotation) {
|
||||
test.map.addAnnotation(annotation);
|
||||
test.checkRendering("line_annotation");
|
||||
|
||||
test.map.jumpTo(CameraOptions().withZoom(test.map.getMaxZoom()));
|
||||
test.map.jumpTo(CameraOptions().withZoom(*test.map.getBounds().maxZoom));
|
||||
test.checkRendering("line_annotation_max_zoom");
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ TEST(Annotations, FillAnnotation) {
|
||||
test.map.addAnnotation(annotation);
|
||||
test.checkRendering("fill_annotation");
|
||||
|
||||
test.map.jumpTo(CameraOptions().withZoom(test.map.getMaxZoom()));
|
||||
test.map.jumpTo(CameraOptions().withZoom(*test.map.getBounds().maxZoom));
|
||||
test.checkRendering("fill_annotation_max_zoom");
|
||||
}
|
||||
|
||||
@@ -481,11 +481,11 @@ TEST(Annotations, ChangeMaxZoom) {
|
||||
annotation.color = Color::red();
|
||||
annotation.width = { 5 };
|
||||
|
||||
test.map.setMaxZoom(6);
|
||||
test.map.setBounds(BoundOptions().withMaxZoom(6));
|
||||
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotation(annotation);
|
||||
test.map.setMaxZoom(14);
|
||||
test.map.jumpTo(CameraOptions().withZoom(test.map.getMaxZoom()));
|
||||
test.map.setBounds(BoundOptions().withMaxZoom(14));
|
||||
test.map.jumpTo(CameraOptions().withZoom(*test.map.getBounds().maxZoom));
|
||||
test.checkRendering("line_annotation_max_zoom");
|
||||
}
|
||||
|
||||
|
||||
@@ -282,6 +282,32 @@ TEST(Map, ProjectionMode) {
|
||||
EXPECT_EQ(*options.ySkew, 0.0);
|
||||
}
|
||||
|
||||
TEST(Map, BoundOptions) {
|
||||
MapTest<> test;
|
||||
|
||||
LatLngBounds llb = LatLngBounds::hull({-10, -10}, {10, 10});
|
||||
test.map.setBounds(BoundOptions().withMinZoom(4).withMaxZoom(10).withLatLngBounds(llb));
|
||||
auto bounds = test.map.getBounds();
|
||||
|
||||
EXPECT_EQ(*bounds.minZoom, 4);
|
||||
EXPECT_EQ(*bounds.maxZoom, 10);
|
||||
EXPECT_EQ(*bounds.bounds, llb);
|
||||
}
|
||||
|
||||
TEST(Map, DefaultBoundOptions) {
|
||||
MapTest<> test;
|
||||
|
||||
auto bounds = test.map.getBounds();
|
||||
|
||||
EXPECT_TRUE(bounds.minZoom);
|
||||
EXPECT_TRUE(bounds.maxZoom);
|
||||
EXPECT_TRUE(bounds.bounds);
|
||||
|
||||
EXPECT_EQ(*bounds.minZoom, util::MIN_ZOOM);
|
||||
EXPECT_EQ(*bounds.maxZoom, util::DEFAULT_MAX_ZOOM);
|
||||
EXPECT_EQ(*bounds.bounds, LatLngBounds::unbounded());
|
||||
}
|
||||
|
||||
TEST(Map, SetStyleInvalidJSON) {
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user