summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-06-30 12:21:05 +1000
committerQt Continuous Integration System <qt-info@nokia.com>2011-06-30 12:21:05 +1000
commita40bae1990f3216df04b7b56532282d9daed91f8 (patch)
treeb099e0123126b40e93c04c1a95ed6b6e880a2f66
parent8acf30adfa51aba4ee0f2fdd71c9c50e9c759a23 (diff)
parent531a656ad1841c69b4613f27bdea753599b6f710 (diff)
downloadqtlocation-a40bae1990f3216df04b7b56532282d9daed91f8.tar.gz
Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qtlocation-staging
* 'master' of git://scm.dev.nokia.troll.no/qt/qtlocation-staging: MOBILITY-2891: markers
-rw-r--r--examples/declarative/mapviewer/Dialog.qml29
-rw-r--r--examples/declarative/mapviewer/MapComponent.qml171
-rw-r--r--examples/declarative/mapviewer/Marker.qml136
-rw-r--r--examples/declarative/mapviewer/RouteDialog.qml39
-rw-r--r--examples/declarative/mapviewer/mapviewer.qml145
-rw-r--r--examples/declarative/mapviewer/mapviewer.qrc4
-rwxr-xr-xexamples/declarative/mapviewer/resources/marker.pngbin0 -> 1712 bytes
-rwxr-xr-xexamples/declarative/mapviewer/resources/marker_hovered.pngbin0 -> 1684 bytes
-rwxr-xr-xexamples/declarative/mapviewer/resources/marker_selected.pngbin0 -> 1696 bytes
9 files changed, 427 insertions, 97 deletions
diff --git a/examples/declarative/mapviewer/Dialog.qml b/examples/declarative/mapviewer/Dialog.qml
index 2bee59e6..586cc24e 100644
--- a/examples/declarative/mapviewer/Dialog.qml
+++ b/examples/declarative/mapviewer/Dialog.qml
@@ -73,7 +73,7 @@ Item {
color: "lightsteelblue"
opacity: parent.opacity
width: parent.width - gap;
- height: listview.height + titleBar.height + buttonGo.height + gap*2
+ height: listview.height + titleBar.height + buttons.height + gap*2
anchors {
top: parent.top
@@ -135,14 +135,29 @@ Item {
}
}
- Common.Button {
- id: buttonGo
- text: "Go!"
+ Row {
+ id: buttons
anchors.top: listview.bottom
- width: 80; height: 32
anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- dialog.goButtonClicked ()
+ spacing: gap/3
+ height: 32
+ Common.Button {
+ id: buttonClearAll
+ text: "Clear All"
+ width: 80; height: parent.height
+ onClicked: {
+ for (var i = 0; i<length; i++){
+ dialogModel.set(i, {"inputText": ""})
+ }
+ }
+ }
+ Common.Button {
+ id: buttonGo
+ text: "Go!"
+ width: 80; height: parent.height
+ onClicked: {
+ dialog.goButtonClicked ()
+ }
}
}
}
diff --git a/examples/declarative/mapviewer/MapComponent.qml b/examples/declarative/mapviewer/MapComponent.qml
index 2751fbfc..4858e727 100644
--- a/examples/declarative/mapviewer/MapComponent.qml
+++ b/examples/declarative/mapviewer/MapComponent.qml
@@ -51,14 +51,22 @@ Map {
center: defaultCoordinates
property int longPressDuration: 1000
+ property list<Marker> markers
+ property int numberOfMarkers: 0 //actual length of markers array
+ property int counter: 0 // counter for total amount of markers. Resets to 0 when numberOfMarkers = 0
+ property Marker currentMarker
+
property RouteQuery routeQuery: RouteQuery {}
property RouteModel routeModel: RouteModel {
- plugin : map.plugin;
+ plugin : map.plugin
query: routeQuery
onStatusChanged:{
if (status == RouteModel.Ready){
if (count == 1) showRouteInfo()
}
+ else if (status == RouteModel.Error){
+ map.routeError()
+ }
}
}
property GeocodeModel geocodeModel: GeocodeModel {
@@ -66,6 +74,10 @@ Map {
onStatusChanged:{
if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)) map.geocodeFinished()
}
+ onPlacesChanged:
+ {
+ if (count == 1) map.center = get(0).coordinate
+ }
}
signal mousePressed() // replace with
@@ -76,6 +88,16 @@ Map {
signal showRouteInfo()
signal geocodeFinished()
signal showGeocodeInfo()
+ signal moveMarker()
+ signal routeError()
+
+ Component.onCompleted: {
+ markers = []
+ }
+
+ onNumberOfMarkersChanged: {
+ if (numberOfMarkers == 0) counter = 0
+ }
Component {
id: routeDelegate
@@ -85,7 +107,7 @@ Map {
MapMouseArea {
id: routeMouseArea
hoverEnabled: true
- onPressed : {routeTimer.start()}
+ onPressed : {routeTimer.start(); map.state = ""}
onReleased : { if (routeTimer.running) routeTimer.stop() }//SHORT PRESS
onPositionChanged: { if (routeTimer.running) routeTimer.stop()}
@@ -107,9 +129,9 @@ Map {
color: circleMouseArea.containsMouse ? "lime" : "#80FF0000"
center: place.coordinate
MapMouseArea {
- id: circleMouseArea
+ id: cstringsircleMouseArea
hoverEnabled: true
- onPressed : { circleTimer.start()}
+ onPressed : { circleTimer.start(); map.state = ""}
onReleased : { if (circleTimer.running) circleTimer.stop() }//SHORT PRESS
onPositionChanged: {
if (circleTimer.running) circleTimer.stop()
@@ -120,7 +142,7 @@ Map {
id: circleTimer
interval: longPressDuration; running: false; repeat: false
onTriggered: { //LONG PRESS
- map.geocodeFinished()
+ map.showGeocodeInfo()
}
}
}
@@ -154,7 +176,7 @@ Map {
minimum: map.minimumZoomLevel;
maximum: map.maximumZoomLevel;
opacity: 1
- z: map.z + 1
+ z: map.z
anchors {
bottom: parent.bottom;
bottomMargin: 50; rightMargin: 5; leftMargin: 5
@@ -169,9 +191,42 @@ Map {
}
Common.Menu {
+ id: markerMenu
+ orientation: ListView.Vertical
+ z: map.z + 2
+ opacity: 0
+
+ itemHeight: 30;
+ itemWidth: 150
+ x: 0
+ y: 0
+ onClicked: {
+ map.state = ""
+ switch (button) {
+ case 0: {//remove marker
+ map.removeMarker(currentMarker)
+ break;
+ }
+ case 1: {//move marker
+ map.moveMarker()
+ break;
+ }
+ case 2: {//show marker's coordinates
+ map.coordinatesCaptured(currentMarker.coordinate.latitude, currentMarker.coordinate.longitude)
+ break;
+ }
+ case 3: {//calculate route
+ map.calculateRoute(currentMarker)
+ break;
+ }
+ }
+ }
+ }
+
+ Common.Menu {
id: popupMenu
orientation: ListView.Vertical
- z: map.z + 1
+ z: map.z +2
opacity: 0
itemHeight: 30;
@@ -180,14 +235,99 @@ Map {
y: 0
Component.onCompleted: {
- setModel(["Capture"])
+ setModel(["Set Marker","Capture"])
}
+
onClicked: {
- map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude)
+ switch (button) {
+ case 0: { //add Marker
+ addMarker()
+ break;
+ }
+ case 1: {
+ map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude)
+ break;
+ }
+ }
map.state = ""
}
}
+ function addMarker(){
+
+ var marker, myArray
+ counter++
+ marker = Qt.createQmlObject ('Marker {}', map)
+ map.addMapObject(marker)
+
+ //update list of markers
+ myArray = new Array()
+ for (var i = 0; i<numberOfMarkers; i++){
+ myArray.push(markers[i])
+ }
+ myArray.push(marker)
+ markers = myArray
+ ++numberOfMarkers
+ }
+
+ function removeMarker(marker){
+ //update list of markers
+ var myArray = new Array()
+ for (var i = 0; i<map.numberOfMarkers; i++){
+ if (marker != map.markers[i]) myArray.push(map.markers[i])
+ }
+
+ map.removeMapObject(marker)
+ marker.destroy()
+ --map.numberOfMarkers
+ map.markers = myArray
+ }
+
+ function markerLongPress(){
+ var array
+
+ if (currentMarker == markers[numberOfMarkers-1]) array = ["Remove", "Move to", "Coordinates"]
+ else if (numberOfMarkers > 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"]
+ }
+ else array = ["Remove", "Move to", "Coordinates", "Route to next point"]
+
+ markerMenu.setModel(array)
+ map.state = "MarkerPopupMenu"
+ }
+
+ function updateMarkers(){
+ for (var i = 0; i<map.numberOfMarkers; i++){
+ map.markers[i].update()
+ }
+ }
+
+ function calculateRoute(marker){
+ routeQuery.clearWaypoints();
+ var startPointFound = false
+ for (var i = 0; i< numberOfMarkers; i++){
+ if (startPointFound != true){
+ if (markers[i] == marker){
+ startPointFound = true
+ routeQuery.addWaypoint(marker.coordinate)
+ }
+ }
+ else routeQuery.addWaypoint(markers[i].coordinate)
+ }
+ routeQuery.travelModes = RouteQuery.CarTravel
+ routeQuery.routeOptimizations = RouteQuery.ShortestRoute
+ routeModel.update();
+ }
+
+ onCenterChanged: {
+ map.updateMarkers()
+ }
+
+ onZoomLevelChanged:{
+ map.updateMarkers()
+ }
+
MapMouseArea {
id: mouseArea
property int lastX : -1
@@ -203,10 +343,9 @@ Map {
map.mousePressed()
}
onReleased : {
- if (mapTimer.running) { //SHORT PRESS
- mapTimer.stop()
- lastX = -1
- lastY = -1
+ if (mapTimer.running) { mapTimer.stop() //SHORT PRESS
+ lastX = -1
+ lastY = -1
}
}
onPositionChanged: {
@@ -255,6 +394,12 @@ Map {
PropertyChanges { target: popupMenu; opacity: 1}
PropertyChanges { target: popupMenu; x: ((mouseArea.lastX + popupMenu.width > map.width) ? map.width - popupMenu.width : mouseArea.lastX)}
PropertyChanges { target: popupMenu; y: ((mouseArea.lastY + popupMenu.height > map.height) ? map.height - popupMenu.height : mouseArea.lastY)}
+ },
+ State {
+ name: "MarkerPopupMenu"
+ PropertyChanges { target: markerMenu; opacity: 1}
+ PropertyChanges { target: markerMenu; x: ((currentMarker.lastMouseX + markerMenu.width > map.width) ? map.width - markerMenu.width : currentMarker.lastMouseX )}
+ PropertyChanges { target: markerMenu; y: ((currentMarker.lastMouseY + markerMenu.height > map.height) ? map.height - markerMenu.height : currentMarker.lastMouseY)}
}
]
}
diff --git a/examples/declarative/mapviewer/Marker.qml b/examples/declarative/mapviewer/Marker.qml
new file mode 100644
index 00000000..c745ee09
--- /dev/null
+++ b/examples/declarative/mapviewer/Marker.qml
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7;
+import Qt.location 5.0
+import "common" as Common
+
+ MapImage { //to be used inside MapComponent only
+ id: marker
+ source: markerMouseArea.pressed ? "resources/marker_selected.png" : "resources/marker.png" //TODO replace with following lane when QTBUG-20096 fixed
+// source: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? "resources/marker_selected.png" :"resources/marker_hovered.png") : "resources/marker.png"
+ coordinate: Coordinate { latitude : 0; longitude : 0 }
+ offset.x: -13
+ offset.y: -32
+ property alias lastMouseX: markerMouseArea.lastX
+ property alias lastMouseY: markerMouseArea.lastY
+ property alias text: markerIndex.text
+
+ Component.onCompleted: {
+ coordinate = mouseArea.lastCoordinate
+ }
+
+ MapMouseArea {
+ id: markerMouseArea
+ property int dX: 0
+ property int dY: 0
+ property int lastX: -1
+ property int lastY: -1
+ hoverEnabled: true
+ onPressed: {
+ marker.z++
+ var newX, newY, oldX, oldY
+ newX = map.toScreenPosition(mouse.coordinate).x
+ newY = map.toScreenPosition(mouse.coordinate).y
+ oldX = map.toScreenPosition(marker.coordinate).x
+ oldY = map.toScreenPosition(marker.coordinate).y
+ dX = oldX - newX
+ dY = oldY - newY
+ lastX = mouse.x
+ lastY = mouse.y
+
+ markerTimer.start()
+ map.currentMarker = marker
+ map.state = ""
+ }
+ onReleased: {
+ if (markerTimer.running) markerTimer.stop();
+ marker.z--
+ }
+
+ onPositionChanged: {
+ var newX, newY
+ if (markerTimer.running) markerTimer.stop();
+ if (mouse.button == Qt.LeftButton){
+ lastX = mouse.x
+ lastY = mouse.y
+ newX = map.toScreenPosition(mouse.coordinate).x + dX
+ newY = map.toScreenPosition(mouse.coordinate).y + dY
+ marker.coordinate = map.toCoordinate(Qt.point(newX,newY))
+ textArea.x = map.toScreenPosition(marker.coordinate).x + offset.x
+ textArea.y = map.toScreenPosition(marker.coordinate).y + offset.y
+ }
+ }
+
+ Timer {
+ id: markerTimer
+ interval: 1000
+ running: false
+ repeat: false
+ onTriggered: {
+ map.markerLongPress()
+ }
+ }
+ }
+
+ Item {
+ id: textArea
+ width: 26
+ height: 32
+ x: map.toScreenPosition(marker.coordinate).x + offset.x
+ y: map.toScreenPosition(marker.coordinate).y + offset.y
+ Text {
+ id: markerIndex
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ z: marker.z
+ color: "white"
+ font.bold: true
+ Component.onCompleted: {
+ text = map.counter
+ }
+ }
+ }
+
+ function update(){
+ textArea.x = map.toScreenPosition(marker.coordinate).x + marker.offset.x
+ textArea.y = map.toScreenPosition(marker.coordinate).y + marker.offset.y
+ }
+ }
diff --git a/examples/declarative/mapviewer/RouteDialog.qml b/examples/declarative/mapviewer/RouteDialog.qml
index a8cdf3b5..2d675c3e 100644
--- a/examples/declarative/mapviewer/RouteDialog.qml
+++ b/examples/declarative/mapviewer/RouteDialog.qml
@@ -74,7 +74,7 @@ Item {
color: "lightsteelblue"
opacity: 1
width: parent.width - gap*2;
- height: options.height + gap*3 + buttonGo.height + titleBar.height
+ height: options.height + gap*3 + buttons.height + titleBar.height
anchors {
top: parent.top
@@ -366,15 +366,40 @@ Item {
}
}
- Common.Button {
- id: buttonGo
- text: "Go!"
+ Row {
+ id: buttons
anchors.top: options.bottom
anchors.topMargin: gap
- width: 80; height: 32
anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- dialog.goButtonClicked ()
+ spacing: gap/3
+ height: 32
+ Common.Button {
+ text: "Clear"
+ width: 80; height: parent.height
+ onClicked: {
+ if (byCoordinates == true){
+ latFrom.text = ""
+ longFrom.text = ""
+ latTo.text = ""
+ longTo.text = ""
+ }
+ else {
+ streetFrom.text = ""
+ cityFrom.text = ""
+ countryFrom.text = ""
+ streetTo.text = ""
+ cityTo.text = ""
+ countryTo.text = ""
+ }
+ }
+ }
+
+ Common.Button {
+ text: "Go!"
+ width: 80; height: parent.height
+ onClicked: {
+ dialog.goButtonClicked ()
+ }
}
}
}
diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml
index 116f5ef7..a687f3a0 100644
--- a/examples/declarative/mapviewer/mapviewer.qml
+++ b/examples/declarative/mapviewer/mapviewer.qml
@@ -237,7 +237,6 @@ FocusScope {
}
}
-
//=====================Dialogs=====================
Message {
id: messageDialog
@@ -248,6 +247,13 @@ FocusScope {
onCancelButtonClicked: {
page.state = ""
}
+ onOpacityChanged: {
+ if (opacity == 0 ) state = ""
+ }
+
+ onStateChanged: {
+ console.log ("message state = " + state)
+ }
states: [
State{
@@ -258,47 +264,27 @@ FocusScope {
State{
name: "GeocodeError"
PropertyChanges { target: messageDialog; title: "Geocode Error" }
- PropertyChanges { target: messageDialog; text: "Unable to find location for the given address." }
+ PropertyChanges { target: messageDialog; text: "Unable to find location for the given address" }
},
State{
name: "UnknownGeocodeError"
PropertyChanges { target: messageDialog; title: "Geocode Error" }
- PropertyChanges { target: messageDialog; text: "Unknown geocode error. Try again" }
+ PropertyChanges { target: messageDialog; text: "Unsuccessful geocode" }
},
State{
name: "AmbiguousGeocode"
PropertyChanges { target: messageDialog; title: "Ambiguous geocode" }
- PropertyChanges { target: messageDialog; text: "Several results found for the given address, please specify location" }
- },
- State{
- name: "Coordinates"
- PropertyChanges { target: messageDialog; title: "Coordinates" }
- PropertyChanges { target: messageDialog; text: "Several results found for the given address, please specify location" }
- },
- State{
- name: "LatitudeNotANumber"
- PropertyChanges { target: messageDialog; title: "Input Error" }
- PropertyChanges { target: messageDialog; text: "Latitude is not a number" }
- },
- State{
- name: "LatitudeOutOfScope"
- PropertyChanges { target: messageDialog; title: "Input Error" }
- PropertyChanges { target: messageDialog; text: "Latitude should be in a range (-90,90)" }
- },
- State{
- name: "LongitudeNotANumber"
- PropertyChanges { target: messageDialog; title: "Input Error" }
- PropertyChanges { target: messageDialog; text: "Longitude is not a number" }
- },
- State{
- name: "LongitudeOutOfScope"
- PropertyChanges { target: messageDialog; title: "Input Error" }
- PropertyChanges { target: messageDialog; text: "Longitude should be in a range (-180,180)" }
+ 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: "NoAddress"
- PropertyChanges { target: messageDialog; title: "Address" }
- PropertyChanges { target: messageDialog; text: "Current location doesn't have address" }
+ name: "RouteError"
+ PropertyChanges { target: messageDialog; title: "Route Error" }
+ PropertyChanges { target: messageDialog; text: "Unable to find a route for the given points"}
},
State{
name: "LocationInfo"
@@ -464,18 +450,41 @@ FocusScope {
onGoButtonClicked: {
page.state = ""
messageDialog.state = ""
- var latitude = dialogModel.get(0).inputText
- var longtitude = dialogModel.get(1).inputText
- verifyLatitude(latitude)
- verifyLongitude(longtitude)
+ reverseGeocodeCoordinate.latitude = dialogModel.get(0).inputText
+ reverseGeocodeCoordinate.longtitude = dialogModel.get(1).inputText
+ map.geocodeModel.query = reverseGeocodeCoordinate
+ map.geocodeModel.update();
+ }
- if (messageDialog.state == "") {
- reverseGeocodeCoordinate.latitude = latitude
- reverseGeocodeCoordinate.longitude = longtitude
- map.geocodeModel.query = reverseGeocodeCoordinate
- map.geocodeModel.update();
- }
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+ }
+
+//Get new coordinates for marker
+ Dialog {
+ id: coordinatesDialog
+ title: "New coordinates"
+ z: mainMenu.z + 1
+
+ Component.onCompleted: {
+ var obj = [["Latitude", ""],["Longitude", ""]]
+ 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
}
onCancelButtonClicked: {
@@ -483,6 +492,7 @@ FocusScope {
}
}
+
//=====================Map=====================
MapComponent{
id: map
@@ -519,7 +529,7 @@ FocusScope {
else dist = dist + " m"
messageDialog.title = "Route info"
- messageDialog.text = "<b>Travel time:</b> " + hours + "h:"+ minutes + "m:" + seconds +"s<br/><b>Distance:</b> " + dist;
+ messageDialog.text = "<b>Travel time:</b> " + hours + "h:"+ minutes + "m<br/><b>Distance:</b> " + dist;
page.state = "Message"
}
@@ -527,10 +537,12 @@ FocusScope {
onGeocodeFinished:{
var street, district, city, county, state, countryCode, country, latitude, longitude, text
- if (map.geocodeModel.count == 0) messageDialog.state = "GeocodeError"
- else if (map.geocodeModel.count > 1) messageDialog.state = "AmbiguousGeocode"
- else if (map.status == GeocodeModel.Error) messageDialog.state = "UnknownGeocodeError"
- else messageDialog.state = "LocationInfo"
+ if (map.geocodeModel.status == GeocodeModel.Ready){
+ if (map.geocodeModel.count == 0) messageDialog.state = "UnknownGeocodeError"
+ else if (map.geocodeModel.count > 1) messageDialog.state = "AmbiguousGeocode"
+ else messageDialog.state = "LocationInfo";
+ }
+ else if (map.geocodeModel.status == GeocodeModel.Error) messageDialog.state = "GeocodeError"
page.state = "Message"
}
@@ -538,11 +550,18 @@ FocusScope {
messageDialog.state = "LocationInfo"
page.state = "Message"
}
+
+ onMoveMarker: {
+ page.state = "Coordinates"
+ }
+
+ onRouteError: {
+ messageDialog.state = "RouteError"
+ }
}
function geocodeMessage(){
var street, district, city, county, state, countryCode, country, latitude, longitude, text
- map.center = map.geocodeModel.get(0).coordinate
latitude = map.geocodeModel.get(0).coordinate.latitude
longitude = map.geocodeModel.get(0).coordinate.longitude
street = map.geocodeModel.get(0).address.street
@@ -572,28 +591,6 @@ FocusScope {
return rndedNum;
}
- function verifyLongitude(longitude){
- var lng
- if (isNaN(longitude)) messageDialog.state = "LongitudeNotANumber"
- else {
- lng = parseFloat(longitude)
- if ((lng> 180) || (lng<-180)) {
- messageDialog.state = "LongitudeOutOfScope"
- }
- }
- }
-
- function verifyLatitude(latitude){
- var lat
- if (isNaN(latitude)) messageDialog.state = "LatitudeNotANumber"
- else {
- lat = parseFloat(latitude)
- if ((lat> 90) || (lat<-90)) {
- messageDialog.state = "LatitudeOutOfScope"
- }
- }
- }
-
//=====================States of page=====================
states: [
State {
@@ -617,6 +614,10 @@ FocusScope {
PropertyChanges { target: geocodeDialog; opacity: 1 }
},
State {
+ name: "Coordinates"
+ PropertyChanges { target: coordinatesDialog; opacity: 1 }
+ },
+ State {
name: "Message"
PropertyChanges { target: messageDialog; opacity: 1 }
},
@@ -659,6 +660,10 @@ FocusScope {
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
Transition {
+ to: "Coordinates"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
to: "Message"
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
diff --git a/examples/declarative/mapviewer/mapviewer.qrc b/examples/declarative/mapviewer/mapviewer.qrc
index d5aae792..3f622246 100644
--- a/examples/declarative/mapviewer/mapviewer.qrc
+++ b/examples/declarative/mapviewer/mapviewer.qrc
@@ -26,5 +26,9 @@
<file>resources/option_button_selected.png</file>
<file>resources/option_button.png</file>
<file>MapComponent.qml</file>
+ <file>Marker.qml</file>
+ <file>resources/marker.png</file>
+ <file>resources/marker_selected.png</file>
+ <file>resources/marker_hovered.png</file>
</qresource>
</RCC>
diff --git a/examples/declarative/mapviewer/resources/marker.png b/examples/declarative/mapviewer/resources/marker.png
new file mode 100755
index 00000000..e2375e3c
--- /dev/null
+++ b/examples/declarative/mapviewer/resources/marker.png
Binary files differ
diff --git a/examples/declarative/mapviewer/resources/marker_hovered.png b/examples/declarative/mapviewer/resources/marker_hovered.png
new file mode 100755
index 00000000..a974e721
--- /dev/null
+++ b/examples/declarative/mapviewer/resources/marker_hovered.png
Binary files differ
diff --git a/examples/declarative/mapviewer/resources/marker_selected.png b/examples/declarative/mapviewer/resources/marker_selected.png
new file mode 100755
index 00000000..5d97a17d
--- /dev/null
+++ b/examples/declarative/mapviewer/resources/marker_selected.png
Binary files differ