summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-12-08 18:45:30 -0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2016-12-09 11:28:31 -0200
commitd6b8866975d9d0b43119ab5cfadd0dc89e4aa51e (patch)
treeda331ee3791e1e1f7c9a0764dfbc477d97732d55 /platform/qt
parent97df99c134a5c4adbf083af0b1e5f8c9713dbb1f (diff)
downloadqtlocation-mapboxgl-d6b8866975d9d0b43119ab5cfadd0dc89e4aa51e.tar.gz
[Qt] Allow strings as data source in the QML Item
Data values starting with ':' will be assumed to be a resource.
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/qmlapp/main.qml10
-rw-r--r--platform/qt/src/qquickmapboxgl.cpp11
2 files changed, 18 insertions, 3 deletions
diff --git a/platform/qt/qmlapp/main.qml b/platform/qt/qmlapp/main.qml
index 6e6f290e43..fd62193b42 100644
--- a/platform/qt/qmlapp/main.qml
+++ b/platform/qt/qmlapp/main.qml
@@ -323,6 +323,16 @@ ApplicationWindow {
source.data = ":source2.geojson"
}
}
+ RadioButton {
+ text: "Route 3"
+ exclusiveGroup: sourceGroup
+ onClicked: {
+ source.data = '{ "type": "FeatureCollection", "features": \
+ [{ "type": "Feature", "properties": {}, "geometry": { \
+ "type": "LineString", "coordinates": [[ 24.934938848018646, \
+ 60.16830257086771 ], [ 24.943315386772156, 60.16227776476442 ]]}}]}'
+ }
+ }
}
}
diff --git a/platform/qt/src/qquickmapboxgl.cpp b/platform/qt/src/qquickmapboxgl.cpp
index b17d8bfe3e..579bea72f2 100644
--- a/platform/qt/src/qquickmapboxgl.cpp
+++ b/platform/qt/src/qquickmapboxgl.cpp
@@ -290,9 +290,14 @@ bool QQuickMapboxGL::parseStyleSource(QQuickMapboxGLMapParameter *param)
source["url"] = param->property("url");
m_sourceChanges << source;
} else if (sourceType == "geojson") {
- QFile geojson(param->property("data").toString());
- geojson.open(QIODevice::ReadOnly);
- source["data"] = geojson.readAll();
+ auto data = param->property("data").toString();
+ if (data.startsWith(':')) {
+ QFile geojson(data);
+ geojson.open(QIODevice::ReadOnly);
+ source["data"] = geojson.readAll();
+ } else {
+ source["data"] = data.toUtf8();
+ }
m_sourceChanges << source;
} else {
m_error = QGeoServiceProvider::UnknownParameterError;