From 2d214c76899c2fdc3271411273f42c45ff83903a Mon Sep 17 00:00:00 2001 From: Natalia Shubina Date: Fri, 1 Jul 2011 10:46:20 +1000 Subject: MOBILITY-2891: fixes for routing, geocoding and markers --- examples/declarative/mapviewer/MapComponent.qml | 31 +++++-- examples/declarative/mapviewer/RouteDialog.qml | 4 +- examples/declarative/mapviewer/common/Menu.qml | 4 +- examples/declarative/mapviewer/mapviewer.qml | 106 ++++++++++-------------- 4 files changed, 71 insertions(+), 74 deletions(-) diff --git a/examples/declarative/mapviewer/MapComponent.qml b/examples/declarative/mapviewer/MapComponent.qml index 4858e727..5ea33db5 100644 --- a/examples/declarative/mapviewer/MapComponent.qml +++ b/examples/declarative/mapviewer/MapComponent.qml @@ -129,7 +129,7 @@ Map { color: circleMouseArea.containsMouse ? "lime" : "#80FF0000" center: place.coordinate MapMouseArea { - id: cstringsircleMouseArea + id: circleMouseArea hoverEnabled: true onPressed : { circleTimer.start(); map.state = ""} onReleased : { if (circleTimer.running) circleTimer.stop() }//SHORT PRESS @@ -234,10 +234,6 @@ Map { x: 0 y: 0 - Component.onCompleted: { - setModel(["Set Marker","Capture"]) - } - onClicked: { switch (button) { case 0: { //add Marker @@ -248,11 +244,24 @@ Map { map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude) break; } + case 2: { + map.deleteAllMarkers() + break; + } } map.state = "" } } + function deleteAllMarkers(){ + for (var i = 0; i 2){ - if (currentMarker == markers[numberOfMarkers-2]) array = ["Remove", "Move to", "Coordinates", "Route to next point"] - else array = ["Remove", "Move to", "Coordinates", "Route to next points"] + if (currentMarker == markers[numberOfMarkers-2]) array = ["Delete", "Move to", "Coordinates", "Route to next point"] + else array = ["Delete", "Move to", "Coordinates", "Route to next points"] } - else array = ["Remove", "Move to", "Coordinates", "Route to next point"] + else array = ["Delete", "Move to", "Coordinates", "Route to next point"] markerMenu.setModel(array) map.state = "MarkerPopupMenu" @@ -326,6 +335,7 @@ Map { onZoomLevelChanged:{ map.updateMarkers() + zoomSlider.value = map.zoomLevel } MapMouseArea { @@ -374,6 +384,9 @@ Map { id: mapTimer interval: longPressDuration; running: false; repeat: false onTriggered: { //LONG PRESS + if (numberOfMarkers != 0) popupMenu.setModel(["Set Marker","Capture","Delete all markers"]) + else popupMenu.setModel(["Set Marker","Capture"]) + map.state = "PopupMenu" } } diff --git a/examples/declarative/mapviewer/RouteDialog.qml b/examples/declarative/mapviewer/RouteDialog.qml index 2d675c3e..8ee2eab0 100644 --- a/examples/declarative/mapviewer/RouteDialog.qml +++ b/examples/declarative/mapviewer/RouteDialog.qml @@ -325,7 +325,7 @@ Item { TextWithLabel { id: streetTo width: parent.width - fromLabel2.width - gap*3 - text: "Ann st" + text: "Brunswick st" label: "street" enabled: address.enabled anchors { @@ -339,7 +339,7 @@ Item { TextWithLabel { id: cityTo width: streetTo.width - text: "Brisbane" + text: "New Farm" label: "city" enabled: address.enabled anchors { diff --git a/examples/declarative/mapviewer/common/Menu.qml b/examples/declarative/mapviewer/common/Menu.qml index 05dc17e4..b246060d 100644 --- a/examples/declarative/mapviewer/common/Menu.qml +++ b/examples/declarative/mapviewer/common/Menu.qml @@ -96,9 +96,9 @@ Item { text: label; elide: Text.ElideLeft font.bold: true; - color: index == menuView.currentIndex ? "crimson" :"white" + color: enabledItem ? ((index == menuView.currentIndex) ? "crimson" :"white") : "dimgrey" style: Text.Raised; - styleColor: "dimgrey" + styleColor:"dimgrey" anchors.verticalCenter: parent.verticalCenter Component.onCompleted: { if (menuView.orientation == ListView.Horizontal){ diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml index a687f3a0..e14b4f98 100644 --- a/examples/declarative/mapviewer/mapviewer.qml +++ b/examples/declarative/mapviewer/mapviewer.qml @@ -54,7 +54,6 @@ FocusScope { z:2 } - Common.TitleBar { id: titleBar; z: mainMenu.z; width: parent.width; height: 40; opacity: 0.9; text: "QML mapviewer example" onClicked: { Qt.quit() } @@ -247,13 +246,6 @@ FocusScope { onCancelButtonClicked: { page.state = "" } - onOpacityChanged: { - if (opacity == 0 ) state = "" - } - - onStateChanged: { - console.log ("message state = " + state) - } states: [ State{ @@ -276,11 +268,6 @@ FocusScope { PropertyChanges { target: messageDialog; title: "Ambiguous geocode" } PropertyChanges { target: messageDialog; text: map.geocodeModel.count + " results found for the given address, please specify location" } }, -// State{ -// name: "NoAddress" -// PropertyChanges { target: messageDialog; title: "Address" } -// PropertyChanges { target: messageDialog; text: "Current location doesn't have address" } -// }, State{ name: "RouteError" PropertyChanges { target: messageDialog; title: "Route Error" } @@ -298,6 +285,7 @@ FocusScope { RouteDialog { id: routeDialog z: mainMenu.z + 1 +// property int success: 0 Coordinate { id: endCoordinate } Coordinate { id: startCoordinate } @@ -307,37 +295,31 @@ FocusScope { GeocodeModel { id: tempGeocodeModel plugin : map.plugin - property int successfulGeocodeCount: 0 + property int success: 0 onStatusChanged:{ - if ((status == GeocodeModel.Ready) && (successfulGeocodeCount == 0)) { - ++successfulGeocodeCount - startCoordinate = tempGeocodeModel.get(0).coordinate - - query = endAddress - update(); - } - else if ((status == GeocodeModel.Ready) && (successfulGeocodeCount == 1)) { - ++successfulGeocodeCount - endCoordinate = tempGeocodeModel.get(0).coordinate - - map.routeQuery.clearWaypoints(); - map.center = startCoordinate - map.routeQuery.addWaypoint(startCoordinate) - map.routeQuery.addWaypoint(endCoordinate) - map.routeQuery.travelModes = routeDialog.travelMode - map.routeQuery.routeOptimizations = routeDialog.routeOptimization - map.routeModel.update(); - } - else if ((status == GeocodeModel.Ready) && (count == 0 )){ - messageDialog.state = "GeocodeError" - page.state = "Message" - } - else if ((status == GeocodeModel.Ready) && (count > 1 )){ - messageDialog.state = "AmbiguousGeocode" - page.state = "Message" + if ((status == GeocodeModel.Ready) && (count == 1)) { + success++ + if (success == 1){ + startCoordinate.latitude = get(0).coordinate.latitude + startCoordinate.longitude = get(0).coordinate.longitude + clear() + query = endAddress + update(); + } + if (success == 2) + { + endCoordinate.latitude = get(0).coordinate.latitude + endCoordinate.longitude = get(0).coordinate.longitude + success = 0 + routeDialog.calculateRoute() + } } - else if (status == GeocodeModel.Error) { - messageDialog.state = "UnknownGeocodeError" + else if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)){ + if ((status == GeocodeModel.Ready) && (count == 0 )) messageDialog.state = "GeocodeError" + else if ((status == GeocodeModel.Ready) && (count > 1 )) messageDialog.state = "AmbiguousGeocode" + else if (status == GeocodeModel.Error) messageDialog.state = "UnknownGeocodeError" + + success = 0 page.state = "Message" } } @@ -352,22 +334,16 @@ FocusScope { endCoordinate.latitude = routeDialog.endLatitude endCoordinate.longitude = routeDialog.endLongitude - map.routeQuery.clearWaypoints(); - map.center = startCoordinate - map.routeQuery.addWaypoint(startCoordinate) - map.routeQuery.addWaypoint(endCoordinate) - map.routeQuery.travelModes = routeDialog.travelMode - map.routeQuery.routeOptimizations = routeDialog.routeOptimization - map.routeModel.update(); + calculateRoute() } else { startAddress.country = routeDialog.startCountry startAddress.street = routeDialog.startStreet - startAddress.district = routeDialog.startCity + startAddress.city = routeDialog.startCity endAddress.country = routeDialog.endCountry endAddress.street = routeDialog.endStreet - endAddress.district = routeDialog.endCity + endAddress.city = routeDialog.endCity tempGeocodeModel.query = startAddress tempGeocodeModel.update(); @@ -378,6 +354,16 @@ FocusScope { onCancelButtonClicked: { page.state = "" } + + function calculateRoute(){ + map.routeQuery.clearWaypoints(); + map.center = startCoordinate + map.routeQuery.addWaypoint(startCoordinate) + map.routeQuery.addWaypoint(endCoordinate) + map.routeQuery.travelModes = routeDialog.travelMode + map.routeQuery.routeOptimizations = routeDialog.routeOptimization + map.routeModel.update(); + } } //Search Dialog @@ -417,6 +403,7 @@ FocusScope { onGoButtonClicked: { page.state = "" + messageDialog.state = "" geocodeAddress.street = dialogModel.get(0).inputText geocodeAddress.district = dialogModel.get(1).inputText geocodeAddress.city = dialogModel.get(2).inputText @@ -424,6 +411,7 @@ FocusScope { geocodeAddress.state = dialogModel.get(4).inputText geocodeAddress.countryCode = dialogModel.get(5).inputText geocodeAddress.country = dialogModel.get(6).inputText + map.geocodeModel.clear() map.geocodeModel.query = geocodeAddress map.geocodeModel.update(); } @@ -452,7 +440,8 @@ FocusScope { messageDialog.state = "" reverseGeocodeCoordinate.latitude = dialogModel.get(0).inputText - reverseGeocodeCoordinate.longtitude = dialogModel.get(1).inputText + reverseGeocodeCoordinate.longitude = dialogModel.get(1).inputText + map.geocodeModel.clear() map.geocodeModel.query = reverseGeocodeCoordinate map.geocodeModel.update(); } @@ -473,18 +462,12 @@ FocusScope { setModel(obj) } - Coordinate { - id: newCoordinate - } - onGoButtonClicked: { page.state = "" messageDialog.state = "" - newCoordinate.latitude = dialogModel.get(0).inputText - newCoordinate.longitude = dialogModel.get(1).inputText - - map.currentMarker.coordinate = newCoordinate - map.center = newCoordinate + map.currentMarker.coordinate.latitude = dialogModel.get(0).inputText + map.currentMarker.coordinate.longitude = dialogModel.get(1).inputText + map.center = map.currentMarker.coordinate } onCancelButtonClicked: { @@ -557,6 +540,7 @@ FocusScope { onRouteError: { messageDialog.state = "RouteError" + page.state = "Message" } } -- cgit v1.2.3