diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2017-05-11 17:23:23 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2017-05-11 19:28:59 +0300 |
commit | d6ce5a410efc116da90cd65af34821d9b9ad4334 (patch) | |
tree | fb1e1843c47cb7fbf7b8148dacb4af173e36dfb2 | |
parent | d45c177e8a23eefcc94930af9fa085e61136bb94 (diff) |
[Qt] Make it possible to add a layer before another layer
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 4 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index f60ad8e67..50dace066 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -223,8 +223,8 @@ public: QMapbox::CustomLayerRenderFunction, QMapbox::CustomLayerDeinitializeFunction, void* context, - char* before = NULL); - void addLayer(const QVariantMap ¶ms); + const QString& before = QString()); + void addLayer(const QVariantMap ¶ms, const QString& before = QString()); bool layerExists(const QString &id); void removeLayer(const QString &id); diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index a1749ff45..130a5fc47 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1338,7 +1338,7 @@ void QMapboxGL::addCustomLayer(const QString &id, QMapbox::CustomLayerRenderFunction renderFn, QMapbox::CustomLayerDeinitializeFunction deinitFn, void *context, - char *before) + const QString& before) { d_ptr->mapObj->addLayer(std::make_unique<mbgl::style::CustomLayer>( id.toStdString(), @@ -1348,13 +1348,14 @@ void QMapboxGL::addCustomLayer(const QString &id, (mbgl::style::CustomLayerRenderFunction)renderFn, reinterpret_cast<mbgl::style::CustomLayerDeinitializeFunction>(deinitFn), context), - before ? mbgl::optional<std::string>(before) : mbgl::optional<std::string>()); + before.isEmpty() ? mbgl::optional<std::string>() : mbgl::optional<std::string>(before.toStdString())); } /*! Adds a style layer to the map as specified by the \l {https://www.mapbox.com/mapbox-gl-style-spec/#root-layers}{Mapbox style specification} with - \a params. + \a params. The layer will be added under the layer specified by \a before, if specified. + Otherwise it will be added as the topmost layer. This example shows how to add a layer that will be used to show a route line on the map. Note that nothing will be drawn until we set paint properties using setPaintProperty(). @@ -1370,7 +1371,7 @@ void QMapboxGL::addCustomLayer(const QString &id, /note The source must exist prior to adding a layer. */ -void QMapboxGL::addLayer(const QVariantMap ¶ms) +void QMapboxGL::addLayer(const QVariantMap ¶ms, const QString& before) { using namespace mbgl::style; using namespace mbgl::style::conversion; @@ -1381,7 +1382,8 @@ void QMapboxGL::addLayer(const QVariantMap ¶ms) return; } - d_ptr->mapObj->addLayer(std::move(*layer)); + d_ptr->mapObj->addLayer(std::move(*layer), + before.isEmpty() ? mbgl::optional<std::string>() : mbgl::optional<std::string>(before.toStdString())); } /*! |