diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-22 12:04:34 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-04-20 20:55:51 +0300 |
commit | 8ff17ffc9af865b1a1735e4759d234c7e62ba79e (patch) | |
tree | 20eaa3c1a97ddd99aa99267c62482ee43bc4fa27 /platform | |
parent | 0d4ccd4e441b7b777e191d47157f51678d448292 (diff) | |
download | qtlocation-mapboxgl-8ff17ffc9af865b1a1735e4759d234c7e62ba79e.tar.gz |
[Qt] Expose {add,remove}CustomLayer
Diffstat (limited to 'platform')
-rw-r--r-- | platform/qt/include/qmapbox.hpp | 16 | ||||
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 8 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 23 |
3 files changed, 47 insertions, 0 deletions
diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp index d9a9f37f30..937d895a7f 100644 --- a/platform/qt/include/qmapbox.hpp +++ b/platform/qt/include/qmapbox.hpp @@ -42,6 +42,22 @@ struct Q_DECL_EXPORT CameraOptions { Q_DECL_EXPORT NetworkMode networkMode(); Q_DECL_EXPORT void setNetworkMode(NetworkMode); +// This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters. +struct Q_DECL_EXPORT CustomLayerRenderParameters { + double width; + double height; + double latitude; + double longitude; + double zoom; + double bearing; + double pitch; + double altitude; +}; + +typedef void (*CustomLayerInitializeFunction)(void* context) ; +typedef void (*CustomLayerRenderFunction)(void* context, const CustomLayerRenderParameters&); +typedef void (*CustomLayerDeinitializeFunction)(void* context); + } Q_DECLARE_METATYPE(QMapbox::Coordinate); diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index 6e1368ea95..7a7389bfec 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -168,6 +168,14 @@ public: void setMargins(const QMargins &margins); QMargins margins() const; + void addCustomLayer(const QString &id, + QMapbox::CustomLayerInitializeFunction, + QMapbox::CustomLayerRenderFunction, + QMapbox::CustomLayerDeinitializeFunction, + void* context, + char* before = NULL); + void removeCustomLayer(const QString& id); + public slots: void render(); void connectionEstablished(); diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index e904c38947..df0e89a53d 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -542,6 +542,29 @@ QMargins QMapboxGL::margins() const ); } +void QMapboxGL::addCustomLayer(const QString &id, + QMapbox::CustomLayerInitializeFunction initFn, + QMapbox::CustomLayerRenderFunction renderFn, + QMapbox::CustomLayerDeinitializeFunction deinitFn, + void *context_, + char *before) +{ + d_ptr->mapObj->addCustomLayer( + id.toStdString(), + reinterpret_cast<mbgl::CustomLayerInitializeFunction>(initFn), + // This cast is safe as long as both mbgl:: and QMapbox:: + // CustomLayerRenderParameters members remains the same. + (mbgl::CustomLayerRenderFunction)renderFn, + reinterpret_cast<mbgl::CustomLayerDeinitializeFunction>(deinitFn), + context_, + before == NULL ? nullptr : before); +} + +void QMapboxGL::removeCustomLayer(const QString& id) +{ + d_ptr->mapObj->removeCustomLayer(id.toStdString()); +} + void QMapboxGL::render() { d_ptr->mapObj->render(); |