diff options
author | Timo Ojala <timo.ojala@digia.com> | 2011-12-19 15:59:44 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-20 23:32:59 +0100 |
commit | 9df969cccf184d9f345eabea8cd46d053d5138b3 (patch) | |
tree | 47b0c5ff1c1273496aa040bf39cf704fe36e2b20 /examples | |
parent | 19d46e65e51a66fde6550772698d8b543a5d5665 (diff) | |
download | qtlocation-9df969cccf184d9f345eabea8cd46d053d5138b3.tar.gz |
Added route calculation via markers to mapviewer
Change-Id: I86b5fb41cec9a61dfbd630914b0b67f3f661bc16
Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Reviewed-by: Natalia Shubina <natalia.shubina@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/mapviewer/content/map/MapComponent.qml | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/declarative/mapviewer/content/map/MapComponent.qml b/examples/declarative/mapviewer/content/map/MapComponent.qml index 821edc28..ed08792b 100644 --- a/examples/declarative/mapviewer/content/map/MapComponent.qml +++ b/examples/declarative/mapviewer/content/map/MapComponent.qml @@ -623,6 +623,11 @@ Map { break; } + case "Calculate Route": { + calculateRoute() + break; + } + } map.state = "" } @@ -767,6 +772,10 @@ Map { popupMenu.addItem("Remove items") } + if (map.markers.length>=2) { + popupMenu.addItem("Calculate Route") + } + if (map.markers.length>1) { popupMenu.addItem("Draw Polyline") @@ -919,28 +928,19 @@ Map { // markerMenu.addItem("Move to") map.state = "MarkerPopupMenu" } -/* - function calculateRoute(marker){ + + function calculateRoute(){ routeQuery.clearWaypoints(); - var startPointFound = false var count = map.markers.length for (var i = 0; i< count; i++){ - if (startPointFound != true){ - if (markers[i] == marker){ - startPointFound = true - routeQuery.addWaypoint(marker.coordinate) - } - } - else routeQuery.addWaypoint(markers[i].coordinate) + routeQuery.addWaypoint(markers[i].coordinate) } routeQuery.travelModes = RouteQuery.CarTravel routeQuery.routeOptimizations = RouteQuery.ShortestRoute - for (i=0; i<9; i++) { - routeQuery.setFeatureWeight(i, 0) - } + routeQuery.setFeatureWeight(0, 0) routeModel.update(); } -*/ + function roundNumber(number, digits) { var multiple = Math.pow(10, digits); return Math.round(number * multiple) / multiple; |