diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-02-20 15:43:08 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-02-25 08:01:23 +0000 |
commit | 351e07dc2c96f70867dca6aaf7d2eb2919ba3d01 (patch) | |
tree | b4ae04117d6d8657b4b9a4886bab2e658dfcf3f9 /src/location/doc/snippets/declarative/routing.qml | |
parent | ebf8bfec10bae10f14e03bee58b23915540490a2 (diff) | |
download | qtlocation-351e07dc2c96f70867dca6aaf7d2eb2919ba3d01.tar.gz |
Fix QtLocation QML snippets
Most of the snippets did not work and/or had outdated API usage.
Change-Id: Ib8949ab6d007c4eaa3638fb40473bf6d217edd36
Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/location/doc/snippets/declarative/routing.qml')
-rw-r--r-- | src/location/doc/snippets/declarative/routing.qml | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/src/location/doc/snippets/declarative/routing.qml b/src/location/doc/snippets/declarative/routing.qml index 8f03ea37..cc091672 100644 --- a/src/location/doc/snippets/declarative/routing.qml +++ b/src/location/doc/snippets/declarative/routing.qml @@ -39,32 +39,47 @@ ****************************************************************************/ //! [QtQuick import] -import QtQuick 2.0 +import QtQuick 2.3 //! [QtQuick import] +import QtPositioning 5.3 //! [QtLocation import] import QtLocation 5.3 //! [QtLocation import] Item { - //! [RouteManeuver] - Text { - text: "Distance till next maneuver: " + routeManeuver.distanceToNextInstruction + " meters, estimated time: " + routeManeuver.timeToNextInstruction + " seconds." + width: 1000 + height: 400 + + Plugin { + id: aPlugin + name: "osm" } - //! [RouteManeuver] - //! [RouteSegment] - Text { - text: "Segment distance " + routeSegment.distance + " meters, " + routeSegment.path.length + " points." + RouteQuery { + id: aQuery + waypoints: [ + { latitude: -27.575, longitude: 153.088}, + { latitude: -27.465, longitude: 153.023} + ] + travelModes: RouteQuery.CarTravel + routeOptimizations: RouteQuery.ShortestRoute } - //! [RouteSegment] - //! [Route Maneuver List] + //! [Route Maneuver List1] RouteModel { id: routeModel // model initialization + //! [Route Maneuver List1] + plugin: aPlugin + autoUpdate: true + query: aQuery + //! [Route Maneuver List2] } + ListView { + id: listview + anchors.fill: parent spacing: 10 model: routeModel.status == RouteModel.Ready ? routeModel.get(0).segments : null visible: model ? true : false @@ -74,10 +89,25 @@ Item { property bool hasManeuver : modelData.maneuver && modelData.maneuver.valid visible: hasManeuver Text { text: (1 + index) + "." } + Text { text: hasManeuver ? modelData.maneuver.instructionText : "" } + //! [Route Maneuver List2] + property RouteManeuver routeManeuver: modelData.maneuver + property RouteSegment routeSegment: modelData + + //! [RouteManeuver] + Text { + text: "Distance till next maneuver: " + routeManeuver.distanceToNextInstruction + + " meters, estimated time: " + routeManeuver.timeToNextInstruction + " seconds." + } + //! [RouteManeuver] + + //! [RouteSegment] Text { - text: hasManeuver ? modelData.maneuver.instructionText : "" + text: "Segment distance " + routeSegment.distance + " meters, " + routeSegment.path.length + " points." } + //! [RouteSegment] + //! [Route Maneuver List3] } } - //! [Route Maneuver List] + //! [Route Maneuver List3] } |