diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index 79eb672d1..ac143066e 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 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 58158c182..581a1c411 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1465,6 +1465,23 @@ void QMapboxGL::removeLayer(const QString& id) d_ptr->mapObj->getStyle().removeLayer(id.toStdString()); } +/*! + List of all existing layer ids from the current style. +*/ +QList QMapboxGL::layerIds() const +{ + const auto &layers = d_ptr->mapObj->getStyle().getLayers(); + + QList 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.