[Qt] Added add/remove style source method
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
14
platform/qt/src/qt_geojson.hpp
Normal file
14
platform/qt/src/qt_geojson.hpp
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user