diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-07 16:10:49 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-11 17:01:32 +0300 |
commit | b59070590b71a4a433bbffbada7019bc2a3ef550 (patch) | |
tree | cdd73bf350fda533645f0a3817840be46db5c2eb /platform/qt | |
parent | e9259fc03e998e892c92e965d264bca974174fea (diff) | |
download | qtlocation-mapboxgl-b59070590b71a4a433bbffbada7019bc2a3ef550.tar.gz |
[Qt] Added set style paint properties method
Diffstat (limited to 'platform/qt')
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 1 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index 121f1debb4..ad1f5e702c 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -175,6 +175,7 @@ public: void removeAnnotation(QMapbox::AnnotationID); void setLayoutProperty(const QString &layer, const QString &property, const QVariant &value); + void setPaintProperty(const QString &layer, const QString &property, const QVariant &value, const QString &klass = QString()); bool isRotating() const; bool isScaling() const; diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 1bf213554d..a8fc51b236 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -469,6 +469,29 @@ void QMapboxGL::setLayoutProperty(const QString& layer_, const QString& property d_ptr->mapObj->update(mbgl::Update::RecalculateStyle); } +void QMapboxGL::setPaintProperty(const QString& layer_, const QString& property, const QVariant& value, const QString& klass_) +{ + using namespace mbgl::style; + + Layer* layer = d_ptr->mapObj->getLayer(layer_.toStdString()); + if (!layer) { + qWarning() << "Layer not found:" << layer_; + return; + } + + mbgl::optional<std::string> klass; + if (!klass_.isEmpty()) { + klass = klass_.toStdString(); + } + + if (conversion::setPaintProperty(*layer, property.toStdString(), value, klass)) { + qWarning() << "Error setting paint property:" << layer_ << "-" << property; + return; + } + + d_ptr->mapObj->update(mbgl::Update::RecalculateStyle | mbgl::Update::Classes); +} + bool QMapboxGL::isRotating() const { return d_ptr->mapObj->isRotating(); |