diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 95958602b..bf2462e2a 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -750,13 +750,15 @@ std::vector Map::queryRenderedFeatures(const ScreenBox& box, const opti AnnotationIDs Map::queryPointAnnotations(const ScreenBox& box) { auto features = queryRenderedFeatures(box, {{ AnnotationManager::PointLayerID }}); - AnnotationIDs ids; - ids.reserve(features.size()); + std::set set; for (auto &feature : features) { assert(feature.id); assert(*feature.id <= std::numeric_limits::max()); - ids.push_back(static_cast(feature.id->get())); + set.insert(static_cast(feature.id->get())); } + AnnotationIDs ids; + ids.reserve(set.size()); + std::move(set.begin(), set.end(), std::back_inserter(ids)); return ids; } diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index dbe538024..dc4b00170 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -43,9 +43,19 @@ TEST(Annotations, SymbolAnnotation) { test.map.addAnnotation(SymbolAnnotation { Point(0, 0), "default_marker" }); test.checkRendering("point_annotation"); + auto size = test.view.getSize(); + auto screenBox = ScreenBox { {}, { double(size[0]), double(size[1]) } }; + auto features = test.map.queryPointAnnotations(screenBox); + EXPECT_EQ(features.size(), 1u); + + test.map.setZoom(test.map.getMaxZoom()); // FIXME: https://github.com/mapbox/mapbox-gl-native/issues/5419 //test.map.setZoom(test.map.getMaxZoom()); //test.checkRendering("point_annotation"); + test::render(test.map); + + features = test.map.queryPointAnnotations(screenBox); + EXPECT_EQ(features.size(), 1u); } TEST(Annotations, LineAnnotation) {