diff options
author | Tadej Novak <tadej@tano.si> | 2019-10-19 10:02:50 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2019-11-11 23:10:10 +0200 |
commit | 910335c51fffe2c59042fc3ebea93778649195f8 (patch) | |
tree | e1aec40ab8805f5ca9aa90f83b8661f6bd280468 /platform/qt | |
parent | 9bff033277f388c064dee0d1b053b6710a2ac165 (diff) | |
download | qtlocation-mapboxgl-910335c51fffe2c59042fc3ebea93778649195f8.tar.gz |
[qt] Make image source url update possible
Diffstat (limited to 'platform/qt')
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 0bfc6abf73..64431e233f 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -30,6 +30,7 @@ #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/style/sources/image_source.hpp> #include <mbgl/style/transition_options.hpp> #include <mbgl/style/image.hpp> #include <mbgl/renderer/renderer.hpp> @@ -1295,7 +1296,7 @@ bool QMapboxGL::sourceExists(const QString& sourceID) Updates the source \a id with new \a params. If the source does not exist, it will be added like in addSource(). Only - GeoJSON sources can be updated. + image and GeoJSON sources can be updated. */ void QMapboxGL::updateSource(const QString &id, const QVariantMap ¶ms) { @@ -1309,12 +1310,17 @@ void QMapboxGL::updateSource(const QString &id, const QVariantMap ¶ms) } auto sourceGeoJSON = source->as<GeoJSONSource>(); - if (!sourceGeoJSON) { - qWarning() << "Unable to update source: only GeoJSON sources are mutable."; + auto sourceImage = source->as<ImageSource>(); + if (!sourceGeoJSON && !sourceImage) { + qWarning() << "Unable to update source: only GeoJSON and Image sources are mutable."; return; } - if (params.contains("data")) { + if (sourceImage) { + if (params.contains("url")) { + sourceImage->setURL(params["url"].toString().toStdString()); + } + } else if (sourceGeoJSON && params.contains("data")) { Error error; auto result = convert<mbgl::GeoJSON>(params["data"], error); if (result) { |