From 9c6ac04148bea7b9a3e15f5ad4f612858efa85dc Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 30 Sep 2016 16:47:20 +0300 Subject: [PATCH] [core] Fix Map::setLatLng behavior We were erroneously assigning a value to optional (null island), causing it to be a valid anchor for Transform::easeTo. --- src/mbgl/map/map.cpp | 2 +- test/map/map.test.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index d5894504e0e..95958602bc1 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -422,7 +422,7 @@ void Map::moveBy(const ScreenCoordinate& point, const Duration& duration) { } void Map::setLatLng(const LatLng& latLng, const Duration& duration) { - setLatLng(latLng, ScreenCoordinate {}, duration); + setLatLng(latLng, optional {}, duration); } void Map::setLatLng(const LatLng& latLng, optional padding, const Duration& duration) { diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 12d4ff2bcd3..5b66d9b7535 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -26,6 +26,22 @@ struct MapTest { StubFileSource fileSource; }; +TEST(Map, LatLngBehavior) { + MapTest test; + Map map(test.view, test.fileSource, MapMode::Still); + + map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + + map.setLatLngZoom({ 1, 1 }, 0); + auto latLng1 = map.getLatLng(); + + map.setLatLng({ 1, 1 }); + auto latLng2 = map.getLatLng(); + + ASSERT_DOUBLE_EQ(latLng1.latitude, latLng2.latitude); + ASSERT_DOUBLE_EQ(latLng1.longitude, latLng2.longitude); +} + TEST(Map, Offline) { MapTest test; DefaultFileSource fileSource(":memory:", ".");