From ae61b9d35f7a1bce078974524c79328e4b767b78 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 11 Jun 2018 22:20:55 +0200 Subject: [Qt] Add QMapboxGL::layerIds() --- platform/qt/include/qmapboxgl.hpp | 2 ++ platform/qt/src/qmapboxgl.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) 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 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 @@ -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. -- cgit v1.2.1