summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/qt/include/qmapboxgl.hpp4
-rw-r--r--platform/qt/src/qmapboxgl.cpp30
2 files changed, 20 insertions, 14 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index a699b77cec..1af62c7491 100644
--- a/platform/qt/include/qmapboxgl.hpp
+++ b/platform/qt/include/qmapboxgl.hpp
@@ -198,8 +198,8 @@ public:
void updateAnnotation(QMapbox::AnnotationID, const QMapbox::Annotation &);
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);
+ bool setLayoutProperty(const QString &layer, const QString &property, const QVariant &value);
+ bool setPaintProperty(const QString &layer, const QString &property, const QVariant &value);
bool isFullyLoaded() const;
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 09479581bb..05cb5b7f93 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -975,7 +975,7 @@ void QMapboxGL::removeAnnotation(QMapbox::AnnotationID id)
/*!
Sets a layout \a property_ \a value to an existing \a layer. The \a property_ string can be any
as defined by the \l {https://www.mapbox.com/mapbox-gl-style-spec/} {Mapbox style specification}
- for layout properties.
+ for layout properties. Returns true if the operation succeeds, and false otherwise.
This example hides the layer \c route:
@@ -1007,26 +1007,29 @@ void QMapboxGL::removeAnnotation(QMapbox::AnnotationID id)
\li QVariantList
\endtable
*/
-void QMapboxGL::setLayoutProperty(const QString& layer, const QString& property_, const QVariant& value)
+bool QMapboxGL::setLayoutProperty(const QString& layer, const QString& property_, const QVariant& value)
{
using namespace mbgl::style;
Layer* layer_ = d_ptr->mapObj->getStyle().getLayer(layer.toStdString());
if (!layer_) {
qWarning() << "Layer not found:" << layer;
- return;
+ return false;
}
- if (conversion::setLayoutProperty(*layer_, property_.toStdString(), value)) {
- qWarning() << "Error setting layout property:" << layer << "-" << property_;
- return;
+ auto result = conversion::setLayoutProperty(*layer_, property_.toStdString(), value);
+ if (result) {
+ qWarning() << "Error setting layout property" << property_ << "on layer" << layer << ":" << QString::fromStdString(result->message);
+ return false;
}
+
+ return true;
}
/*!
Sets a paint \a property_ \a value to an existing \a layer. The \a property_ string can be any
as defined by the \l {https://www.mapbox.com/mapbox-gl-style-spec/} {Mapbox style specification}
- for paint properties.
+ for paint properties. Returns true if the operation succeeds, and false otherwise.
For paint properties that take a color as \a value, such as \c fill-color, a string such as
\c blue can be passed or a QColor.
@@ -1073,20 +1076,23 @@ void QMapboxGL::setLayoutProperty(const QString& layer, const QString& property_
map->setPaintProperty("route","line-dasharray", lineDashArray);
\endcode
*/
-void QMapboxGL::setPaintProperty(const QString& layer, const QString& property_, const QVariant& value)
+bool QMapboxGL::setPaintProperty(const QString& layer, const QString& property_, const QVariant& value)
{
using namespace mbgl::style;
Layer* layer_ = d_ptr->mapObj->getStyle().getLayer(layer.toStdString());
if (!layer_) {
qWarning() << "Layer not found:" << layer;
- return;
+ return false;
}
- if (conversion::setPaintProperty(*layer_, property_.toStdString(), value)) {
- qWarning() << "Error setting paint property:" << layer << "-" << property_;
- return;
+ auto result = conversion::setPaintProperty(*layer_, property_.toStdString(), value);
+ if (result) {
+ qWarning() << "Error setting paint property" << property_ << "on layer" << layer << ":" << QString::fromStdString(result->message);
+ return false;
}
+
+ return true;
}
/*!