summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-05-26 13:12:23 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-05-26 13:12:23 -0700
commit8ace0d37d10e8174268f259dec38cf88e2494ef0 (patch)
tree40fa3e7f2de753583d959418595fe4afdd52c398
parent27f9a85feaab2cb075c88e5cca73a2267a858444 (diff)
downloadqtlocation-mapboxgl-8ace0d37d10e8174268f259dec38cf88e2494ef0.tar.gz
[core] AnnotationTileLayer vends its own name (#5163)
Fixes #5159.
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp2
-rw-r--r--src/mbgl/annotation/annotation_tile.cpp3
-rw-r--r--src/mbgl/annotation/annotation_tile.hpp7
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp2
-rw-r--r--test/api/annotations.cpp20
5 files changed, 31 insertions, 3 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp
index 1febc757a4..e5f43eb3b6 100644
--- a/src/mbgl/annotation/annotation_manager.cpp
+++ b/src/mbgl/annotation/annotation_manager.cpp
@@ -90,7 +90,7 @@ std::unique_ptr<AnnotationTile> AnnotationManager::getTile(const CanonicalTileID
AnnotationTileLayer& pointLayer = *tile->layers.emplace(
PointLayerID,
- std::make_unique<AnnotationTileLayer>()).first->second;
+ std::make_unique<AnnotationTileLayer>(PointLayerID)).first->second;
LatLngBounds tileBounds(tileID);
diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp
index 8f754ed6da..ba4b69108c 100644
--- a/src/mbgl/annotation/annotation_tile.cpp
+++ b/src/mbgl/annotation/annotation_tile.cpp
@@ -21,6 +21,9 @@ optional<Value> AnnotationTileFeature::getValue(const std::string& key) const {
return optional<Value>();
}
+AnnotationTileLayer::AnnotationTileLayer(const std::string &name_)
+ : name(name_) {}
+
util::ptr<GeometryTileLayer> AnnotationTile::getLayer(const std::string& name) const {
auto it = layers.find(name);
if (it != layers.end()) {
diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp
index 5943eb11c9..d607d563d4 100644
--- a/src/mbgl/annotation/annotation_tile.hpp
+++ b/src/mbgl/annotation/annotation_tile.hpp
@@ -24,11 +24,16 @@ public:
class AnnotationTileLayer : public GeometryTileLayer {
public:
+ AnnotationTileLayer(const std::string&);
+
std::size_t featureCount() const override { return features.size(); }
util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override { return features[i]; }
- std::string getName() const override { return ""; };
+ std::string getName() const override { return name; };
std::vector<util::ptr<const AnnotationTileFeature>> features;
+
+private:
+ std::string name;
};
class AnnotationTile : public GeometryTile {
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index 9b9ea3bf26..3afc6044d7 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -119,7 +119,7 @@ void ShapeAnnotationImpl::updateTile(const CanonicalTileID& tileID, AnnotationTi
return;
AnnotationTileLayer& layer = *tile.layers.emplace(layerID,
- std::make_unique<AnnotationTileLayer>()).first->second;
+ std::make_unique<AnnotationTileLayer>(layerID)).first->second;
for (auto& shapeFeature : shapeTile.features) {
FeatureType featureType = FeatureType::Unknown;
diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp
index 8640ce9dbe..f7554fb65e 100644
--- a/test/api/annotations.cpp
+++ b/test/api/annotations.cpp
@@ -259,3 +259,23 @@ TEST(Annotations, SwitchStyle) {
checkRendering(map, "switch_style");
}
+
+TEST(Annotations, QueryRenderedFeatures) {
+ util::RunLoop loop;
+
+ auto display = std::make_shared<mbgl::HeadlessDisplay>();
+ HeadlessView view(display, 1);
+ StubFileSource fileSource;
+
+ Map map(view, fileSource, MapMode::Still);
+ map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
+ map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
+ const LatLng latLng(0, 0);
+ map.addPointAnnotation(PointAnnotation(latLng, "default_marker"));
+
+ test::render(map);
+
+ auto point = map.pixelForLatLng(latLng);
+ auto features = map.queryRenderedFeatures(point);
+ EXPECT_EQ(features.size(), 1);
+}