[Qt] Add QMapboxGL::layerIds()

This commit is contained in:
Bruno de Oliveira Abinader
2018-06-11 22:20:55 +02:00
parent 9af5172f98
commit ae61b9d35f
2 changed files with 19 additions and 0 deletions

View File

@@ -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,

View File

@@ -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<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.