diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-07 19:16:57 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-11 17:01:32 +0300 |
commit | abff8e42c1c0c4725def0e3bc0cb5e5a029bff21 (patch) | |
tree | 68842a06f4db94cd6c590fdb3208a728aa197236 /platform/qt | |
parent | 18c88301696de16037aaa2d3b9b31fdabc813696 (diff) | |
download | qtlocation-mapboxgl-abff8e42c1c0c4725def0e3bc0cb5e5a029bff21.tar.gz |
[Qt] Added add style layer method
Diffstat (limited to 'platform/qt')
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 3 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 16 |
2 files changed, 17 insertions, 2 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index 1caee09be5..e1dcbfff14 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -205,7 +205,8 @@ public: QMapbox::CustomLayerDeinitializeFunction, void* context, char* before = NULL); - void removeCustomLayer(const QString& id); + void addLayer(const QVariant &value); + void removeLayer(const QString &id); void setFilter(const QString &layer, const QVariant &filter); diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index c793353ac6..2a1cfd6f50 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -637,7 +637,21 @@ void QMapboxGL::addCustomLayer(const QString &id, before ? mbgl::optional<std::string>(before) : mbgl::optional<std::string>()); } -void QMapboxGL::removeCustomLayer(const QString& id) +void QMapboxGL::addLayer(const QVariant& value) +{ + using namespace mbgl::style; + using namespace mbgl::style::conversion; + + Result<std::unique_ptr<Layer>> layer = convert<std::unique_ptr<Layer>>(value); + if (!layer) { + qWarning() << "Unable to add layer:" << layer.error().message; + return; + } + + d_ptr->mapObj->addLayer(std::move(*layer)); +} + +void QMapboxGL::removeLayer(const QString& id) { d_ptr->mapObj->removeLayer(id.toStdString()); } |