summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;