summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-06-11 22:20:55 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-06-12 15:11:45 +0200
commitc0436cc0a96b0bf864cbe3f2cbb8bb72741fa299 (patch)
tree38d2181438c2164ab76b39bc97b929aee5030121
parent9af5172f98a4319ba4d8d9d4cb7a24ac8bd9ea12 (diff)
downloadqtlocation-mapboxgl-upstream/qmapboxgl-layer-ids.tar.gz
[Qt] Add QMapboxGL::layerIds()upstream/qmapboxgl-layer-ids
-rw-r--r--platform/qt/include/qmapboxgl.hpp2
-rw-r--r--platform/qt/src/qmapboxgl.cpp17
2 files changed, 19 insertions, 0 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index 79eb672d1f..ac143066e3 100644
--- a/platform/qt/include/qmapboxgl.hpp
+++ b/platform/qt/include/qmapboxgl.hpp
@@ -236,6 +236,8 @@ public:
bool layerExists(const QString &id);
void removeLayer(const QString &id);
+ QList<QString> layerIds() const;
+
void setFilter(const QString &layer, const QVariant &filter);
// When rendering on a different thread,
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 58158c1822..581a1c4111 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -1466,6 +1466,23 @@ void QMapboxGL::removeLayer(const QString& id)
}
/*!
+ List of all existing layer ids from the current style.
+*/
+QList<QString> QMapboxGL::layerIds() const
+{
+ const auto &layers = d_ptr->mapObj->getStyle().getLayers();
+
+ QList<QString> layerIds;
+ layerIds.reserve(layers.size());
+
+ for (const mbgl::style::Layer *layer : layers) {
+ layerIds.append(QString::fromStdString(layer->getID()));
+ }
+
+ return layerIds;
+}
+
+/*!
Adds the \a image with the identifier \a id that can be used
later by a symbol layer.