diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-08 15:28:56 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-11 17:01:32 +0300 |
commit | abeee2087c151ccc492b2aff60b54dc6f8ec9fd1 (patch) | |
tree | fb614c3289304c915e1476e12ee7c73ed36de712 /platform/qt | |
parent | abff8e42c1c0c4725def0e3bc0cb5e5a029bff21 (diff) | |
download | qtlocation-mapboxgl-abeee2087c151ccc492b2aff60b54dc6f8ec9fd1.tar.gz |
[Qt] Added add/remove style source method
Diffstat (limited to 'platform/qt')
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 3 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 21 | ||||
-rw-r--r-- | platform/qt/src/qt_geojson.hpp | 14 |
3 files changed, 38 insertions, 0 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index e1dcbfff14..e95dc84550 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -199,6 +199,9 @@ public: void setMargins(const QMargins &margins); QMargins margins() const; + void addSource(const QString& sourceID, const QVariant& value); + void removeSource(const QString& sourceID); + void addCustomLayer(const QString &id, QMapbox::CustomLayerInitializeFunction, QMapbox::CustomLayerRenderFunction, diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 2a1cfd6f50..71264faed7 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1,6 +1,7 @@ #include "qmapboxgl_p.hpp" #include "qt_conversion.hpp" +#include "qt_geojson.hpp" #include <mbgl/annotation/annotation.hpp> #include <mbgl/gl/gl.hpp> @@ -8,6 +9,7 @@ #include <mbgl/map/map.hpp> #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/layer.hpp> +#include <mbgl/style/conversion/source.hpp> #include <mbgl/style/layers/custom_layer.hpp> #include <mbgl/style/transition_options.hpp> #include <mbgl/sprite/sprite_image.hpp> @@ -619,6 +621,25 @@ QMargins QMapboxGL::margins() const ); } +void QMapboxGL::addSource(const QString& sourceID, const QVariant& value) +{ + using namespace mbgl::style; + using namespace mbgl::style::conversion; + + Result<std::unique_ptr<Source>> source = convert<std::unique_ptr<Source>>(value, sourceID.toStdString()); + if (!source) { + qWarning() << "Unable to add source:" << source.error().message; + return; + } + + d_ptr->mapObj->addSource(std::move(*source)); +} + +void QMapboxGL::removeSource(const QString& sourceID) +{ + d_ptr->mapObj->removeSource(sourceID.toStdString()); +} + void QMapboxGL::addCustomLayer(const QString &id, QMapbox::CustomLayerInitializeFunction initFn, QMapbox::CustomLayerRenderFunction renderFn, diff --git a/platform/qt/src/qt_geojson.hpp b/platform/qt/src/qt_geojson.hpp new file mode 100644 index 0000000000..cc0b15a6cd --- /dev/null +++ b/platform/qt/src/qt_geojson.hpp @@ -0,0 +1,14 @@ +#include <mbgl/style/conversion/geojson.hpp> + +namespace mbgl { +namespace style { +namespace conversion { + +template <> +Result<GeoJSON> convertGeoJSON(const QVariant&) { + return Error { "not implemented" }; +} + +} // namespace conversion +} // namespace style +} // namespace mbgl |