[Qt] Allow strings as data source in the QML Item
Data values starting with ':' will be assumed to be a resource.
This commit is contained in:
committed by
Thiago Marcos P. Santos
parent
97df99c134
commit
d6b8866975
@@ -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 ]]}}]}'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user