summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTadej Novak <tadej@tano.si>2019-10-19 10:02:50 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-10-21 12:13:20 +0300
commit83a52be2b0fb60fca4b470b613dabc248aa25765 (patch)
tree74c7d0432c0c4dbcea1917fa08ffd793a545fc61
parent5233c75b3f6c73623c5473b2d6573f31f3ddb4b7 (diff)
downloadqtlocation-mapboxgl-83a52be2b0fb60fca4b470b613dabc248aa25765.tar.gz
[qt] Make image source url update possible
-rw-r--r--platform/qt/src/qmapboxgl.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 094eaca5ac..b200d476f7 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -28,6 +28,7 @@
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/symbol_layer.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>
@@ -1326,7 +1327,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 &params)
{
@@ -1340,12 +1341,17 @@ void QMapboxGL::updateSource(const QString &id, const QVariantMap &params)
}
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) {