我想使用 Qt Location 属性在地图上显示路线列表,我能够显示一条路线,但我不知道如何显示多条路线。这是我的代码:
RouteModel {
id: routeModel
plugin: somePlugin
query: RouteQuery {}
Component.onCompleted: {
query.addWaypoint(QtPositioning.coordinate(26.328045523310905, 50.080033033011546));
query.addWaypoint(QtPositioning.coordinate(26.333615791655415, 50.097984054173025));
routeModel.update();
query.addWaypoint(QtPositioning.coordinate(26.291584, 50.199094));
query.addWaypoint(QtPositioning.coordinate(26.288128, 50.188725));
routeModel.update();
}
onStatusChanged: console.debug("current route model status", status, count, errorString)
}
我希望每一对 addWayPoints 都是一条不同的路线。我怎样才能做到这一点?
我用他们对应的 mapitemview 添加了多个模型,但它仍然没有用。
RouteModel {
id: routeModel
plugin: somePlugin
query: RouteQuery {}
Component.onCompleted: {
query.addWaypoint(QtPositioning.coordinate(26.328045523310905, 50.080033033011546));
query.addWaypoint(QtPositioning.coordinate(26.333615791655415, 50.097984054173025));
routeModel.update();
}
}
RouteModel {
id: rm
plugin: somePlugin
query: RouteQuery {}
Component.onCompleted: {
query.addWaypoint(QtPositioning.coordinate(26.291584, 50.199094));
query.addWaypoint(QtPositioning.coordinate(26.288128, 50.188725));
rm.update();
}
}
RouteModel {
id: rm1
plugin: somePlugin
query: RouteQuery {}
Component.onCompleted: {
query.addWaypoint(QtPositioning.coordinate(26.278496, 50.203740));
query.addWaypoint(QtPositioning.coordinate(26.272351, 50.185939));
rm.update();
}
}
Map {
id: map
anchors.fill: parent
plugin: somePlugin
center: magione
gesture.enabled: true
zoomLevel: 13
MapItemView {
model: routeModel
delegate: MapRoute {
route: routeData
line.color: "blue"
line.width: 5
smooth: true
}
}
MapItemView {
model: rm
delegate: MapRoute {
route: routeData1
line.color: "green"
line.width: 5
smooth: true
}
}
MapItemView {
model: rm2
delegate: MapRoute {
route: routeData2
line.color: "black"
line.width: 5
smooth: true
}
}
}