summaryrefslogtreecommitdiffstats
path: root/examples/location/mapviewer
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-11-18 10:24:19 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-18 11:53:15 +0100
commit02e88e8349b4c516c855f2f373838a29e9d3e1bb (patch)
treed439538d57af42be14e22377d347eebdc3973dae /examples/location/mapviewer
parent898f292736ced9ae83e7fad2da3006196dfaa8c7 (diff)
Reorder example dir structure according to Qt convention
Causes undesirable example structure in Qt release package Task-number: QTBUG-34907 Change-Id: I47e2205aa6faef388792146b36cf6ae6cae863da Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'examples/location/mapviewer')
-rw-r--r--examples/location/mapviewer/content/dialogs/Message.qml109
-rw-r--r--examples/location/mapviewer/content/dialogs/RouteDialog.qml454
-rw-r--r--examples/location/mapviewer/content/map/3dItem.qml99
-rw-r--r--examples/location/mapviewer/content/map/CircleItem.qml58
-rw-r--r--examples/location/mapviewer/content/map/ImageItem.qml61
-rw-r--r--examples/location/mapviewer/content/map/MapComponent.qml1157
-rw-r--r--examples/location/mapviewer/content/map/Marker.qml114
-rw-r--r--examples/location/mapviewer/content/map/MiniMap.qml83
-rw-r--r--examples/location/mapviewer/content/map/PolygonItem.qml63
-rw-r--r--examples/location/mapviewer/content/map/PolylineItem.qml56
-rw-r--r--examples/location/mapviewer/content/map/RectangleItem.qml74
-rw-r--r--examples/location/mapviewer/content/map/VideoItem.qml91
-rw-r--r--examples/location/mapviewer/demo.ogvbin0 -> 642306 bytes
-rw-r--r--examples/location/mapviewer/icon.pngbin0 -> 5312 bytes
-rw-r--r--examples/location/mapviewer/mapviewer.pro49
-rw-r--r--examples/location/mapviewer/mapviewer.qml722
-rw-r--r--examples/location/mapviewer/mapviewerwrapper.qrc19
-rw-r--r--examples/location/mapviewer/qmlmapviewerwrapper.cpp114
18 files changed, 3323 insertions, 0 deletions
diff --git a/examples/location/mapviewer/content/dialogs/Message.qml b/examples/location/mapviewer/content/dialogs/Message.qml
new file mode 100644
index 00000000..7488eb83
--- /dev/null
+++ b/examples/location/mapviewer/content/dialogs/Message.qml
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation.examples 5.0
+
+Item {
+ id: dialog
+
+ anchors.fill: parent
+
+ property alias title: titleBar.text
+ property alias text: message.text
+ property int gap: 10
+
+ signal okButtonClicked
+ signal cancelButtonClicked
+ opacity: 0
+ enabled: opacity > 0 ? true : false
+
+ Fader {}
+
+ Rectangle {
+ id: dialogRectangle
+
+ color: "#ECECEC"
+ width: parent.width - gap;
+ height: titleBar.height + message.height + okButton.height + gap*3
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ leftMargin: gap/2
+ }
+
+ radius: 5
+
+ TitleBar {
+ id: titleBar;
+ width: parent.width; height: 40;
+ anchors.top: parent.top; anchors.left: parent.left;
+ opacity: 0.9;
+ onClicked: { dialog.cancelButtonClicked() }
+ }
+
+ Text {
+ id: message
+ anchors.horizontalCenter: parent.horizontalCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.top: titleBar.bottom
+ width: dialogRectangle.width - gap
+ anchors.topMargin: gap
+ textFormat: Text.RichText
+ wrapMode: Text.Wrap
+ onLinkActivated: {
+ Qt.openUrlExternally(link)
+ }
+ font.pixelSize: 14
+ }
+
+ Button {
+ id: okButton
+ text: "Ok"
+ anchors.top: message.bottom
+ anchors.topMargin: gap
+ width: 80; height: 32
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ dialog.okButtonClicked ()
+ }
+ }
+ }
+}
diff --git a/examples/location/mapviewer/content/dialogs/RouteDialog.qml b/examples/location/mapviewer/content/dialogs/RouteDialog.qml
new file mode 100644
index 00000000..73e5f3d1
--- /dev/null
+++ b/examples/location/mapviewer/content/dialogs/RouteDialog.qml
@@ -0,0 +1,454 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+import QtLocation.examples 5.0
+
+Dialog {
+ id: dialog
+
+ title: "Route"
+ gap: 6
+
+ property alias startLatitude: latFrom.text
+ property alias startLongitude: longFrom.text
+ property alias endLatitude: latTo.text
+ property alias endLongitude: longTo.text
+ property alias startStreet: streetFrom.text
+ property alias startCity: cityFrom.text
+ property alias startCountry: countryFrom.text
+ property alias endStreet: streetTo.text
+ property alias endCity: cityTo.text
+ property alias endCountry: countryTo.text
+ property alias byCoordinates: coord.enabled
+
+ property int travelMode: RouteQuery.CarTravel // CarTravel, PedestrianTravel, BicycleTravel, PublicTransitTravel, TruckTravel
+ property int routeOptimization: RouteQuery.FastestRoute // ShortestRoute, FastestRoute, MostEconomicRoute, MostScenicRoute
+ property variant features: [] // NoFeature, TollFeature, HighwayFeature, PublicTransitFeature, FerryFeature, TunnelFeature, DirtRoadFeature, ParksFeature, MotorPoolLaneFeature
+ property color fontColorNormal: "#242424"
+ property color fontColorDisabled: "lightgrey"
+ property color backgroundColorNormal: "#ECECEC"
+ property color backgroundColorEnabled: "#98D0FC"
+ property color backgroundColorDisabled: "grey"
+
+ item: Flickable {
+ id: f
+
+ clip: true
+ interactive: height + gap < contentHeight
+ implicitHeight: contentItem.height
+ contentHeight: contentItem.height
+ contentWidth: contentItem.width
+
+ Item {
+ id: contentItem
+ width: f.width
+ height: childrenRect.height
+
+ Column {
+ id: options
+ spacing: gap
+ width: parent.width
+
+ states: [
+ State {
+ name: "Address"
+ PropertyChanges { target: coord; enabled: false }
+ PropertyChanges { target: address; enabled: true }
+ }
+ ]
+
+ //by coordinates
+ Row {
+ id: row1
+ spacing: gap
+ Image {
+ id: optionButtonCoord
+ anchors.verticalCenter:parent.verticalCenter
+ source: coord.enabled ? "../../resources/option_button_selected.png" : "../../resources/option_button.png"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { options.state = "" }
+ }
+ }
+
+ Rectangle {
+ id: coord
+ color: enabled ? backgroundColorEnabled : backgroundColorDisabled
+ radius: 5
+ width:options.width - optionButtonCoord.width - row1.spacing
+ height: longTo.y + longTo.height + gap
+ enabled: true
+
+ //start point
+ Text {
+ id: fromLabel;
+ font.bold: true;
+ enabled: coord.enabled
+ anchors {
+ top: latFrom.top
+ topMargin:latFrom.height + gap/6 - fromLabel.height/2
+ left: parent.left;
+ leftMargin: gap
+ }
+ text: "From"
+ color: enabled ? fontColorNormal : fontColorDisabled
+ font.pixelSize: 14
+ }
+
+ TextWithLabel {
+ id: latFrom
+ width: parent.width - fromLabel.width - gap*3
+ text: "-27.575"
+ label: "latitude"
+ enabled: coord.enabled
+ anchors {
+ left: fromLabel.right
+ leftMargin: gap
+ top: parent.top
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: longFrom
+ width: latFrom.width
+ text: "153.088"
+ label: "longitude"
+ enabled: coord.enabled
+ anchors {
+ left: latFrom.left
+ top: latFrom.bottom
+ topMargin:gap/3
+ }
+ }
+
+ //end point
+ Text {
+ id: toLabel;
+ font.bold: true;
+ width: fromLabel.width
+ enabled: coord.enabled
+ anchors {
+ top: latTo.top
+ topMargin:latTo.height + gap/6 - toLabel.height/2
+ left: parent.left;
+ leftMargin: gap;
+ }
+ text: "To"
+ color: enabled ? fontColorNormal : fontColorDisabled
+ font.pixelSize: 14
+ }
+
+ TextWithLabel {
+ id: latTo
+ width: latFrom.width
+ text: "-27.465"
+ label: "latitude"
+ enabled: coord.enabled
+ anchors {
+ left: toLabel.right
+ leftMargin: gap
+ top: longFrom.bottom
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: longTo
+ width: latTo.width
+ text: "153.023"
+ label: "longitude"
+ enabled: coord.enabled
+ anchors {
+ left: latTo.left
+ top: latTo.bottom
+ topMargin:gap/3
+ }
+ }
+ }
+ }
+
+ //by address
+ Row {
+ id: row2
+ spacing: gap
+
+ Image {
+ id: optionButtonAddress
+ source: address.enabled ? "../../resources/option_button_selected.png" : "../../resources/option_button.png"
+ anchors.verticalCenter: parent.verticalCenter
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { options.state = "Address" }
+ }
+ }
+
+ Rectangle {
+ id: address
+ color: enabled ? backgroundColorEnabled : backgroundColorDisabled
+ radius: 5
+ width:coord.width
+ height: countryTo.y + countryTo.height + gap
+ enabled: false
+
+ //start point
+ Text {
+ id: fromLabel2;
+ font.bold: true;
+ enabled: address.enabled
+ anchors {
+ top: cityFrom.top
+ left: parent.left;
+ leftMargin: gap
+ }
+ text: "From"
+ color: enabled ? fontColorNormal : fontColorDisabled
+ font.pixelSize: 14
+ }
+
+ TextWithLabel {
+ id: streetFrom
+ width: parent.width - fromLabel2.width - gap*3
+ text: "Brandl st"
+ label: "street"
+ enabled: address.enabled
+ anchors {
+ left: fromLabel2.right
+ leftMargin: gap
+ top: parent.top
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: cityFrom
+ width: streetFrom.width
+ text: "Eight Mile Plains"
+ label: "city"
+ enabled: address.enabled
+ anchors {
+ left: streetFrom.left
+ top: streetFrom.bottom
+ topMargin:gap/3
+ }
+ }
+
+ TextWithLabel {
+ id: countryFrom
+ width: streetFrom.width
+ text: "Australia"
+ label: "country"
+ enabled: address.enabled
+ anchors {
+ left: streetFrom.left
+ top: cityFrom.bottom
+ topMargin:gap/3
+ }
+ }
+
+ //end point
+ Text {
+ id: toLabel2;
+ font.bold: true;
+ enabled: address.enabled
+ anchors {
+ top: cityTo.top
+ left: parent.left;
+ leftMargin: gap
+ }
+ text: "To"
+ color: enabled ? fontColorNormal : fontColorDisabled
+ font.pixelSize: 14
+ }
+
+ TextWithLabel {
+ id: streetTo
+ width: parent.width - fromLabel2.width - gap*3
+ text: "Heal st"
+ label: "street"
+ enabled: address.enabled
+ anchors {
+ left: fromLabel2.right
+ leftMargin: gap
+ top: countryFrom.bottom
+ topMargin:gap
+ }
+ }
+
+ TextWithLabel {
+ id: cityTo
+ width: streetTo.width
+ text: "New Farm"
+ label: "city"
+ enabled: address.enabled
+ anchors {
+ left: streetTo.left
+ top: streetTo.bottom
+ topMargin:gap/3
+ }
+ }
+
+ TextWithLabel {
+ id: countryTo
+ width: streetTo.width
+ text: "Australia"
+ label: "country"
+ enabled: address.enabled
+ anchors {
+ left: streetTo.left
+ top: cityTo.bottom
+ topMargin:gap/3
+ }
+ }
+ }
+ }
+ }
+
+ Row {
+ id: routeOptions
+ anchors.top: options.bottom
+ anchors.topMargin: gap
+ anchors.left: parent.left
+ anchors.leftMargin: gap
+ width: parent.width - gap*2
+ height: checkboxToll.height*2 + gap
+ spacing: 0
+ Column {//travel mode
+ spacing: gap/3
+ height: parent.height
+ width: parent.width*0.325
+ Optionbutton {
+ id: optionbuttonVehicle
+ width: parent.width
+ text: "Vehicle"
+ selected: true
+ onClicked: {
+ travelMode = RouteQuery.CarTravel
+ optionbuttonPedestrian.selected = false
+ }
+ }
+ Optionbutton {
+ id: optionbuttonPedestrian
+ width: parent.width
+ text: "Pedestrian"
+ onClicked: {
+ travelMode = RouteQuery.PedestrianTravel
+ optionbuttonVehicle.selected = false
+ }
+ }
+ }
+
+ Column {//Optimization
+ spacing: gap/3
+ height: parent.height
+ width: parent.width*0.275
+ Optionbutton {
+ id: optionbuttonFastest
+ width: parent.width
+ text: "Fastest"
+ selected: true
+ onClicked: {
+ routeOptimization = RouteQuery.FastestRoute
+ optionbuttonShortest.selected = false
+ }
+ }
+ Optionbutton {
+ id: optionbuttonShortest
+ width: parent.width
+ text: "Shortest"
+ onClicked: {
+ routeOptimization = RouteQuery.ShortestRoute
+ optionbuttonFastest.selected = false
+ }
+ }
+ }
+
+ Column {//Route features
+ id: routeFeatures
+ spacing: gap/3
+ height: parent.height
+ width: parent.width*0.4
+ Checkbox {
+ id: checkboxToll
+ width: parent.width
+ text: "Avoid toll roads"
+ onSelectedChanged: {routeFeatures.updateRouteFeatures()}
+ }
+
+ Checkbox {
+ id: checkboxHighways
+ width: parent.width
+ text: "Avoid highways"
+ onSelectedChanged: {routeFeatures.updateRouteFeatures()}
+ }
+
+ function updateRouteFeatures(){
+ features = []
+ var myArray = new Array
+
+ if (checkboxToll.selected) myArray.push(RouteQuery.TollFeature)
+ if (checkboxHighways.selected) myArray.push(RouteQuery.HighwayFeature)
+
+ features = myArray
+ }
+ }
+ }
+ }
+ }
+
+ onClearButtonClicked: {
+ if (byCoordinates == true){
+ latFrom.text = ""
+ longFrom.text = ""
+ latTo.text = ""
+ longTo.text = ""
+ }
+ else {
+ streetFrom.text = ""
+ cityFrom.text = ""
+ countryFrom.text = ""
+ streetTo.text = ""
+ cityTo.text = ""
+ countryTo.text = ""
+ }
+ }
+}
diff --git a/examples/location/mapviewer/content/map/3dItem.qml b/examples/location/mapviewer/content/map/3dItem.qml
new file mode 100644
index 00000000..4c190429
--- /dev/null
+++ b/examples/location/mapviewer/content/map/3dItem.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0;
+import QtLocation 5.0
+import QtQuick 2.0
+import Qt3D 2.0
+import Qt3D.Shapes 2.0
+
+// NOTE: If the creation of this compoment fails, make sure you have the latest
+// qtquick3d (qml2 branch) and qtdeclarative installed.
+// You can test your system with qtquick3d examples.
+MapQuickItem { //to be used inside MapComponent only
+ id: mapItem
+
+ // zoomLevel: 8 // set this if you want the item to follow zoom level changes
+
+ function setGeometry(markers, index) {
+ coordinate.latitude = markers[index].coordinate.latitude
+ coordinate.longitude = markers[index].coordinate.longitude
+ }
+
+ anchorPoint.x: testItem.width/2
+ anchorPoint.y: testItem.height/2
+
+ sourceItem: Item {
+ id: testItem
+ width: 100
+ height: 100
+ Viewport {
+ width: parent.width; height: parent.height
+ renderMode: "BufferedRender"
+ navigation: false // set this true if you want to rotate/zoom with mouse
+ // but that interferes with map panning on 3d item area
+ Cube {
+ scale: 2
+ transform: [
+ Rotation3D {
+ angle: 45
+ axis: Qt.vector3d(1, 0, 1)
+ },
+ Rotation3D {
+ id: spin
+ angle: 0
+ axis: Qt.vector3d(0, 1, 0)
+ }]
+
+ NumberAnimation {
+ target: spin
+ property: "angle"
+ from: 0
+ to: 360; duration: 5000; running: true
+ loops: NumberAnimation.Infinite }
+
+ effect: Effect {
+ color: "#aaca00"
+ texture: "../../icon.png"
+ decal: true
+ }
+ }
+ }
+ }
+}
diff --git a/examples/location/mapviewer/content/map/CircleItem.qml b/examples/location/mapviewer/content/map/CircleItem.qml
new file mode 100644
index 00000000..d7f03402
--- /dev/null
+++ b/examples/location/mapviewer/content/map/CircleItem.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+
+//TODO: remove/refactor me when items are integrated
+
+MapCircle {
+
+ color: "yellow"
+ border.color: "red"
+ border.width: 5
+ smooth: true
+ opacity: 0.5
+
+ function setGeometry(markers, index){
+ center.latitude = markers[index].coordinate.latitude
+ center.longitude = markers[index].coordinate.longitude
+ radius= center.distanceTo(markers[index + 1].coordinate)
+ }
+}
diff --git a/examples/location/mapviewer/content/map/ImageItem.qml b/examples/location/mapviewer/content/map/ImageItem.qml
new file mode 100644
index 00000000..a7146fbf
--- /dev/null
+++ b/examples/location/mapviewer/content/map/ImageItem.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0;
+import QtLocation 5.0
+
+MapQuickItem { //to be used inside MapComponent only
+ id: imageItem
+
+ MapMouseArea {
+ anchors.fill: parent
+ drag.target: parent
+ }
+
+ function setGeometry(markers, index) {
+ coordinate.latitude = markers[index].coordinate.latitude
+ coordinate.longitude = markers[index].coordinate.longitude
+ }
+
+ sourceItem: Image {
+ id: testImage
+ source: "../../icon.png"
+ opacity: 0.7
+ }
+}
diff --git a/examples/location/mapviewer/content/map/MapComponent.qml b/examples/location/mapviewer/content/map/MapComponent.qml
new file mode 100644
index 00000000..e51373a7
--- /dev/null
+++ b/examples/location/mapviewer/content/map/MapComponent.qml
@@ -0,0 +1,1157 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+import QtPositioning 5.2
+import QtLocation.examples 5.0
+
+//! [top]
+Map {
+ id: map
+ zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2
+
+ //! [coord]
+ center {
+ latitude: -27.5796
+ longitude: 153.1003
+ }
+ //! [coord]
+
+ // Enable pinch gestures to zoom in and out
+ gesture.flickDeceleration: 3000
+ gesture.enabled: true
+
+//! [top]
+ property variant markers
+ property variant mapItems
+ property int markerCounter: 0 // counter for total amount of markers. Resets to 0 when number of markers = 0
+ property int currentMarker
+ signal resetState()
+
+ property int lastX : -1
+ property int lastY : -1
+ property int pressX : -1
+ property int pressY : -1
+ property int jitterThreshold : 30
+ property bool followme: false
+ property variant scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000]
+ signal showDistance(string distance);
+ signal requestLocale()
+
+ /* @todo
+ Binding {
+ target: map
+ property: 'center'
+ value: positionSource.position.coordinate
+ when: followme
+ }*/
+
+ PositionSource{
+ id: positionSource
+ active: followme
+
+ onPositionChanged: {
+ map.center = positionSource.position.coordinate
+ }
+ }
+
+ MapCircle {
+ id: poiEightMilePlains
+ center {
+ latitude: -27.5758
+ longitude: 153.0881
+ }
+
+ radius: 1800
+ color: "green"
+ border.width: 2
+ border.color: "#242424"
+ opacity: 0.7
+ }
+
+ MapQuickItem {
+ sourceItem: Text{
+ text: "Eight Mile Plains"
+ color:"#242424"
+ font.bold: true
+ styleColor: "#ECECEC"
+ style: Text.Outline
+ }
+ coordinate {
+ latitude: -27.59
+ longitude: 153.084
+ }
+ anchorPoint.x: 0
+ anchorPoint.y: 0
+ }
+
+ MapQuickItem {
+ id: poiNokia
+ sourceItem: Rectangle { width: 14; height: 14; color: "#1c94fc"; border.width: 2; border.color: "#242424"; smooth: true; radius: 7 }
+ coordinate {
+ latitude: -27.5796
+ longitude: 153.1003
+ }
+ opacity:0.7
+ anchorPoint.x: sourceItem.width/2
+ anchorPoint.y: sourceItem.height/2
+ }
+
+ MapQuickItem {
+ sourceItem: Text{
+ text: "Nokia"
+ color:"#242424"
+ font.bold: true
+ styleColor: "#ECECEC"
+ style: Text.Outline
+ }
+ coordinate: poiNokia.coordinate
+ anchorPoint.x: -poiNokia.sourceItem.width * 0.5
+ anchorPoint.y: poiNokia.sourceItem.height * 1.5
+ }
+
+
+ Slider {
+ id: zoomSlider;
+ minimum: map.minimumZoomLevel;
+ maximum: map.maximumZoomLevel;
+ opacity: 1
+ visible: parent.visible
+ z: map.z + 3
+ anchors {
+ bottom: parent.bottom;
+ bottomMargin: 15; rightMargin: 10; leftMargin: 90
+ left: parent.left
+ }
+ width: parent.width - anchors.rightMargin - anchors.leftMargin
+
+ value: map.zoomLevel
+
+ Binding {
+ target: zoomSlider; property: "value"; value: map.zoomLevel
+ }
+
+ onValueChanged: {
+ map.zoomLevel = value
+ map.state=""
+ map.resetState()
+ }
+ }
+
+ Button {
+ id: languageButton
+ text: "en"
+ width: 30
+ height: 30
+ z: map.z + 2
+ anchors.bottom: zoomSlider.top
+ anchors.bottomMargin: 8
+ anchors.right: zoomSlider.right
+ onClicked: {
+ map.state = "LanguageMenu"
+ }
+ }
+
+ Menu {
+ id:languageMenu
+ horizontalOrientation: false
+ autoWidth: true
+ opacity: 0
+ z: map.z + 4
+ anchors.bottom: languageButton.top
+ anchors.right: languageButton.left
+ onClicked: {
+ switch (button) {
+ case "en":
+ case "fr": {
+ setLanguage(button);
+ break;
+ }
+ case "Other": {
+ map.requestLocale()
+ }
+ }
+ map.state = ""
+ }
+ Component.onCompleted: {
+ addItem("en")
+ addItem("fr")
+ addItem("Other")
+ }
+ }
+
+//! [routemodel0]
+ property RouteQuery routeQuery: RouteQuery {}
+
+ property RouteModel routeModel: RouteModel {
+ plugin : map.plugin
+ query: routeQuery
+//! [routemodel0]
+
+//! [routemodel1]
+ onStatusChanged: {
+ if (status == RouteModel.Ready) {
+ switch (count) {
+ case 0:
+ clearAll() // technically not an error
+ map.routeError()
+ break
+ case 1:
+ routeInfoModel.update()
+ break
+ }
+ } else if (status == RouteModel.Error) {
+ clearAll()
+ map.routeError()
+ }
+ }
+//! [routemodel1]
+
+//! [routemodel2]
+ function clearAll() {
+ routeInfoModel.update()
+ }
+//! [routemodel2]
+//! [routemodel3]
+ }
+//! [routemodel3]
+
+//! [geocodemodel0]
+ property GeocodeModel geocodeModel: GeocodeModel {
+//! [geocodemodel0]
+//! [geocodemodel0 body]
+ plugin: map.plugin
+ onStatusChanged: {
+ if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error))
+ map.geocodeFinished()
+ }
+ onLocationsChanged:
+ {
+ if (count == 1) {
+ map.center.latitude = get(0).coordinate.latitude
+ map.center.longitude = get(0).coordinate.longitude
+ }
+ }
+//! [geocodemodel0 body]
+//! [geocodemodel1]
+ }
+//! [geocodemodel1]
+
+ signal showGeocodeInfo()
+ signal moveMarker()
+
+ signal geocodeFinished()
+ signal routeError()
+ signal coordinatesCaptured(double latitude, double longitude)
+
+ Component.onCompleted: {
+ markers = new Array();
+ mapItems = new Array();
+ }
+
+//! [routedelegate0]
+ Component {
+ id: routeDelegate
+
+ MapRoute {
+ route: routeData
+
+ line.color: routeMouseArea.containsMouse ? "lime" : "red"
+ line.width: 5
+ smooth: true
+ opacity: 0.8
+//! [routedelegate0]
+ MapMouseArea {
+ id: routeMouseArea
+ anchors.fill: parent
+ hoverEnabled: false
+
+ onPressed : {
+ map.resetState();
+ map.state = ""
+ map.lastX = mouse.x + parent.x
+ map.lastY = mouse.y + parent.y
+ map.pressX = mouse.x + parent.x
+ map.pressY = mouse.y + parent.y
+ }
+
+ onPositionChanged: {
+ if (map.state != "RoutePopupMenu" ||
+ Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold ||
+ Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) {
+ map.state = ""
+ }
+ if ((mouse.button == Qt.LeftButton) & (map.state == "")) {
+ map.lastX = mouse.x + parent.x
+ map.lastY = mouse.y + parent.y
+ }
+ }
+
+ onPressAndHold:{
+ if (Math.abs(map.pressX - parent.x- mouse.x ) < map.jitterThreshold
+ && Math.abs(map.pressY - parent.y - mouse.y ) < map.jitterThreshold) {
+ map.state = "RoutePopupMenu"
+ }
+ }
+ }
+ }
+//! [routedelegate1]
+ }
+//! [routedelegate1]
+
+//! [pointdel0]
+ Component {
+ id: pointDelegate
+
+ MapCircle {
+ radius: 1000
+ color: circleMouseArea.containsMouse ? "lime" : "red"
+ opacity: 0.6
+ center: locationData.coordinate
+//! [pointdel0]
+ MapMouseArea {
+ anchors.fill:parent
+ id: circleMouseArea
+ hoverEnabled: false
+
+ onPressed : {
+ map.resetState();
+ map.state = ""
+ map.lastX = mouse.x + parent.x
+ map.lastY = mouse.y + parent.y
+ map.pressX = mouse.x + parent.x
+ map.pressY = mouse.y + parent.y
+ }
+
+ onPositionChanged: {
+ if (map.state != "PointPopupMenu" ||
+ Math.abs(map.pressX - parent.x- mouse.x ) > map.jitterThreshold ||
+ Math.abs(map.pressY - parent.y -mouse.y ) > map.jitterThreshold) {
+ map.state = ""
+ if (pressed) parent.radius = parent.center.distanceTo(mouseToCoordinate(mouse))
+ }
+ if ((mouse.button == Qt.LeftButton) & (map.state == "")) {
+ map.lastX = mouse.x + parent.x
+ map.lastY = mouse.y + parent.y
+ }
+ }
+
+ onPressAndHold:{
+ if (Math.abs(map.pressX - parent.x- mouse.x ) < map.jitterThreshold
+ && Math.abs(map.pressY - parent.y - mouse.y ) < map.jitterThreshold) {
+ map.state = "PointPopupMenu"
+ }
+ }
+ }
+//! [pointdel1]
+ }
+ }
+//! [pointdel1]
+
+//! [routeinfodel0]
+ Component {
+ id: routeInfoDelegate
+ Row {
+ spacing: 10
+//! [routeinfodel0]
+ Text {
+ id: indexText
+ text: index + 1
+ color: "#242424"
+ font.bold: true
+ font.pixelSize: 14
+ }
+//! [routeinfodel1]
+ Text {
+ id: instructionText
+ text: instruction
+ color: "#242424"
+ wrapMode: Text.Wrap
+//! [routeinfodel1]
+ width: textArea.width - indexText.width - distanceText.width - spacing*4
+//! [routeinfodel2]
+ font.pixelSize: 14
+ }
+ Text {
+ id: distanceText
+ text: distance
+ color: "#242424"
+ font.bold: true
+ font.pixelSize: 14
+ }
+ }
+ }
+//! [routeinfodel2]
+
+ Component{
+ id: routeInfoHeader
+ Item {
+ width: textArea.width
+ height: travelTime.height + line.anchors.topMargin + line.height
+ Text {
+ id: travelTime
+ text: routeInfoModel.travelTime
+ color: "#242424"
+ font.bold: true
+ font.pixelSize: 14
+ anchors.left: parent.left
+ }
+ Text {
+ id: distance
+ text: routeInfoModel.distance
+ color: "#242424"
+ font.bold: true
+ font.pixelSize: 14
+ anchors.right: parent.right
+ }
+ Rectangle {
+ id: line
+ color: "#242424"
+ width: parent.width
+ height: 2
+ anchors.left: parent.left
+ anchors.topMargin: 1
+ anchors.top: distance.bottom
+ }
+ }
+ }
+
+//! [routeinfomodel]
+ ListModel {
+ id: routeInfoModel
+
+ property string travelTime
+ property string distance
+
+ function update() {
+ clear()
+ if (routeModel.count > 0) {
+ for (var i = 0; i < routeModel.get(0).segments.length; i++) {
+ append({
+ "instruction": routeModel.get(0).segments[i].maneuver.instructionText,
+ "distance": formatDistance(routeModel.get(0).segments[i].maneuver.distanceToNextInstruction)
+ });
+ }
+ }
+ travelTime = routeModel.count == 0 ? "" : formatTime(routeModel.get(0).travelTime)
+ distance = routeModel.count == 0 ? "" : formatDistance(routeModel.get(0).distance)
+ }
+ }
+//! [routeinfomodel]
+
+//! [routeview]
+ MapItemView {
+ model: routeModel
+ delegate: routeDelegate
+ autoFitViewport: true
+ }
+//! [routeview]
+
+//! [geocodeview]
+ MapItemView {
+ model: geocodeModel
+ delegate: pointDelegate
+ }
+//! [geocodeview]
+
+ Item {
+ id: infoTab
+ parent: scale.parent
+ z: map.z + 2
+ height: parent.height - 180
+ width: parent.width
+ x: -5 - infoRect.width
+ y: 60
+ visible: (routeInfoModel.count > 0)
+ Image {
+ id: catchImage
+ source: "../../resources/catch.png"
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (infoTab.x == -5) infoTab.x -= infoRect.width
+ else infoTab.x = -5
+ map.state = ""
+ }
+ }
+ }
+
+ Behavior on x {
+ PropertyAnimation { properties: "x"; duration: 300; easing.type: Easing.InOutQuad }
+ }
+
+ Rectangle {
+ id: infoRect
+ width: parent.width - catchImage.sourceSize.width
+ height: parent.height
+ color: "#ECECEC"
+ opacity: 1
+ radius: 5
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: false
+ }
+ Item {
+ id: textArea
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ width: parent.width -15
+ height: parent.height - 20
+ ListView {
+ id: routeInfoView
+ model: routeInfoModel
+ delegate: routeInfoDelegate
+ header: routeInfoHeader
+ anchors.fill: parent
+ clip: true
+ }
+ }
+ }
+ }
+
+
+ Item {//scale
+ id: scale
+ parent: zoomSlider.parent
+ visible: scaleText.text != "0 m"
+ z: map.z + 2
+ opacity: 0.6
+ anchors {
+ bottom: zoomSlider.top;
+ bottomMargin: 8;
+ left: zoomSlider.left
+ }
+ Image {
+ id: scaleImageLeft
+ source: "../../resources/scale_end.png"
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ }
+ Image {
+ id: scaleImage
+ source: "../../resources/scale.png"
+ anchors.bottom: parent.bottom
+ anchors.left: scaleImageLeft.right
+ }
+ Image {
+ id: scaleImageRight
+ source: "../../resources/scale_end.png"
+ anchors.bottom: parent.bottom
+ anchors.left: scaleImage.right
+ }
+ Text {
+ id: scaleText
+ color: "#004EAE"
+ horizontalAlignment: Text.AlignHCenter
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.bottomMargin: 3
+ text: "0 m"
+ font.pixelSize: 14
+ }
+ Component.onCompleted: {
+ map.calculateScale();
+ }
+ }
+
+ Timer {
+ id: scaleTimer
+ interval: 100
+ running: false
+ repeat: false
+ onTriggered: {
+ map.calculateScale()
+ }
+ }
+
+ onCenterChanged:{
+ scaleTimer.restart()
+ if (map.followme)
+ if (map.center != positionSource.position.coordinate) map.followme = false
+ }
+
+ onZoomLevelChanged:{
+ scaleTimer.restart()
+ if (map.followme) map.center = positionSource.position.coordinate
+ }
+
+ onWidthChanged:{
+ scaleTimer.restart()
+ }
+
+ onHeightChanged:{
+ scaleTimer.restart()
+ }
+
+ Menu {
+ id: markerMenu
+ horizontalOrientation: false
+ autoWidth: true
+ z: map.z + 4
+ opacity: 0
+
+ width: 150
+ x: 0
+ y: 0
+ onClicked: {
+ map.state = ""
+ switch (button) {
+ case "Delete": {//remove marker
+ map.deleteMarker(currentMarker)
+ break;
+ }
+ case "Move to": {//move marker
+ map.moveMarker()
+ break;
+ }
+ case "Coordinates": {//show marker's coordinates
+ map.coordinatesCaptured(markers[currentMarker].coordinate.latitude, markers[currentMarker].coordinate.longitude)
+ break;
+ }
+ case "Distance to next point": {
+ showDistance(formatDistance(map.markers[currentMarker].coordinate.distanceTo(map.markers[currentMarker+1].coordinate)));
+ break;
+ }
+ case "Route to next points"://calculate route
+ case "Route to next point": {
+ map.calculateRoute()
+ break;
+ }
+ case "Draw...": {
+ map.drawItemPopup()
+ break;
+ }
+ }
+ }
+ }
+
+ Menu {
+ id: drawMenu
+ horizontalOrientation: false
+ autoWidth: true
+ z: map.z + 4
+ opacity: 0
+
+ width: 150
+ x: 0
+ y: 0
+ onClicked: {
+ map.state = ""
+ switch (button) {
+ case "Polyline": {
+ addGeoItem("PolylineItem")
+ break;
+ }
+
+ case "Rectangle": {
+ addGeoItem("RectangleItem")
+ break;
+ }
+
+ case "Circle": {
+ addGeoItem("CircleItem")
+ break;
+ }
+
+ case "Polygon": {
+ addGeoItem("PolygonItem")
+ break;
+ }
+
+ case "Image": {
+ addGeoItem("ImageItem")
+ break;
+ }
+
+ case "Video": {
+ addGeoItem("VideoItem")
+ break;
+ }
+
+ case "3D QML Item": {
+ addGeoItem("3dItem")
+ break;
+ }
+ }
+ }
+ }
+
+ Menu {
+ id: popupMenu
+ horizontalOrientation: false
+ autoWidth: true
+ z: map.z + 4
+ opacity: 0
+
+ width: 150
+ x: 0
+ y: 0
+
+ onClicked: {
+ switch (button) {
+ case "Add Marker": {
+ addMarker()
+ break;
+ }
+ case "Get coordinate": {
+ map.coordinatesCaptured(mouseArea.lastCoordinate.latitude, mouseArea.lastCoordinate.longitude)
+ break;
+ }
+ case "Fit Viewport To Map Items": {
+ map.fitViewportToMapItems()
+ break;
+ }
+
+ case "Delete all markers": {
+ deleteMarkers()
+ break;
+ }
+
+ case "Delete all items": {
+ deleteMapItems()
+ break;
+ }
+ }
+ map.state = ""
+ }
+ }
+
+ Menu {
+ id: routeMenu
+ horizontalOrientation: false
+ autoWidth: true
+ z: map.z + 4
+ opacity: 0
+
+ width: 150
+ x: 0
+ y: 0
+
+ onClicked: {
+ switch (button) {
+ case "Delete": {//delete route
+ routeModel.reset()
+ routeInfoModel.update()
+ break;
+ }
+ }
+ map.state = ""
+ }
+ Component.onCompleted: {
+ addItem("Delete")
+ }
+ }
+
+ Menu {
+ id: pointMenu
+ horizontalOrientation: false
+ autoWidth: true
+ z: map.z + 4
+ opacity: 0
+
+ width: 150
+ x: 0
+ y: 0
+
+ onClicked: {
+ switch (button) {
+ case "Info": {
+ map.showGeocodeInfo()
+ break;
+ }
+ case "Delete": {
+ geocodeModel.reset()
+ break;
+ }
+ }
+ map.state = ""
+ }
+ Component.onCompleted: {
+ addItem("Info")
+ addItem("Delete")
+ }
+ }
+
+ Rectangle {
+ id: infoLabel
+ width: backgroundRect.width + 10
+ height: infoText.height + 5
+ y: 440
+ anchors.left: map.left
+ z: map.z + 1
+ color: "dimgrey"
+ opacity: (infoText.text !="") ? 0.8 : 0
+
+ Behavior on opacity {
+ NumberAnimation { duration: 200 }
+ }
+ Text {
+ id: infoText
+ width: parent.width
+ elide: Text.ElideLeft
+ maximumLineCount: 4
+ wrapMode: Text.Wrap
+ font.bold: true
+ font.pixelSize: 14
+ style: Text.Raised;
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.leftMargin: 5
+ anchors.rightMargin: 5
+ color: "white"
+ }
+ }
+
+ MapMouseArea {
+ id: mouseArea
+ property variant lastCoordinate
+ anchors.fill: parent
+
+ onPressed : {
+ map.resetState();
+ map.state = ""
+ map.lastX = mouse.x
+ map.lastY = mouse.y
+ map.pressX = mouse.x
+ map.pressY = mouse.y
+ lastCoordinate = mouseArea.mouseToCoordinate(mouse)
+ // if (mouse.button == Qt.MiddleButton)
+ // addMarker()
+ }
+
+ onPositionChanged: {
+ if (map.state != "PopupMenu" ||
+ Math.abs(map.pressX - mouse.x ) > map.jitterThreshold ||
+ Math.abs(map.pressY - mouse.y ) > map.jitterThreshold) {
+ map.state = ""
+ }
+ if ((mouse.button == Qt.LeftButton) & (map.state == "")) {
+ // if ((map.lastX != -1) && (map.lastY != -1)) {
+ // var dx = mouse.x - map.lastX
+ // var dy = mouse.y - map.lastY
+ // map.pan(-dx, -dy)
+ // }
+ map.lastX = mouse.x
+ map.lastY = mouse.y
+ }
+ }
+
+ onDoubleClicked: {
+ map.center = mouseArea.mouseToCoordinate(mouse)
+ if (mouse.button == Qt.LeftButton){
+ map.zoomLevel += 1
+ } else if (mouse.button == Qt.RightButton) map.zoomLevel -= 1
+ lastX = -1
+ lastY = -1
+ }
+
+ onPressAndHold:{
+ if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold
+ && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) {
+ popupMenu.clear()
+ popupMenu.addItem("Add Marker")
+ popupMenu.addItem("Get coordinate")
+ popupMenu.addItem("Fit Viewport To Map Items")
+
+ if (map.markers.length>0) {
+ popupMenu.addItem("Delete all markers")
+ }
+
+ if (map.mapItems.length>0) {
+ popupMenu.addItem("Delete all items")
+ }
+ map.state = "PopupMenu"
+ }
+ }
+ }
+
+
+ Keys.onPressed: {
+ if ((event.key == Qt.Key_Plus) || (event.key == Qt.Key_VolumeUp)) {
+ map.zoomLevel += 1
+ } else if ((event.key == Qt.Key_Minus) || (event.key == Qt.Key_VolumeDown)){
+ map.zoomLevel -= 1
+ }
+ }
+
+ function calculateScale(){
+ var coord1, coord2, dist, text, f
+ f = 0
+ coord1 = map.toCoordinate(Qt.point(0,scale.y))
+ coord2 = map.toCoordinate(Qt.point(0+scaleImage.sourceSize.width,scale.y))
+ dist = Math.round(coord1.distanceTo(coord2))
+
+ if (dist === 0) {
+ // not visible
+ } else {
+ for (var i = 0; i < scaleLengths.length-1; i++) {
+ if (dist < (scaleLengths[i] + scaleLengths[i+1]) / 2 ) {
+ f = scaleLengths[i] / dist
+ dist = scaleLengths[i]
+ break;
+ }
+ }
+ if (f === 0) {
+ f = dist / scaleLengths[i]
+ dist = scaleLengths[i]
+ }
+ }
+
+ text = formatDistance(dist)
+ scaleImage.width = (scaleImage.sourceSize.width * f) - 2 * scaleImageLeft.sourceSize.width
+ scaleText.text = text
+ }
+
+
+ function deleteMarkers(){
+ var count = map.markers.length
+ for (var i = 0; i<count; i++){
+ map.removeMapItem(map.markers[i])
+ map.markers[i].destroy()
+ }
+ map.markers = []
+ markerCounter = 0
+ }
+
+ function deleteMapItems(){
+ var count = map.mapItems.length
+ for (var i = 0; i<count; i++){
+ map.removeMapItem(map.mapItems[i])
+ map.mapItems[i].destroy()
+ }
+ map.mapItems = []
+ }
+
+ function addMarker(){
+ var count = map.markers.length
+ markerCounter++
+ var marker = Qt.createQmlObject ('Marker {}', map)
+ map.addMapItem(marker)
+ marker.z = map.z+1
+
+ //update list of markers
+ var myArray = new Array()
+ for (var i = 0; i<count; i++){
+ myArray.push(markers[i])
+ }
+ myArray.push(marker)
+ markers = myArray
+ }
+
+ function addGeoItem(item){
+ var count = map.mapItems.length
+ var co = Qt.createComponent(item+'.qml')
+ if (co.status == Component.Ready) {
+ var o = co.createObject(map)
+ o.setGeometry(map.markers, currentMarker)
+ map.addMapItem(o)
+ //update list of items
+ var myArray = new Array()
+ for (var i = 0; i<count; i++){
+ myArray.push(mapItems[i])
+ }
+ myArray.push(o)
+ mapItems = myArray
+
+ } else {
+ console.log(item + " is not supported right now, please call us later.")
+ }
+ }
+
+ function deleteMarker(index){
+ //update list of markers
+ var myArray = new Array()
+ var count = map.markers.length
+ for (var i = 0; i<count; i++){
+ if (index != i) myArray.push(map.markers[i])
+ }
+
+ map.removeMapItem(map.markers[index])
+ map.markers[index].destroy()
+ map.markers = myArray
+ if (markers.length == 0) markerCounter = 0
+ }
+
+ function markerPopup(){
+ var array
+ var length = map.markers.length
+
+ markerMenu.clear()
+ markerMenu.addItem("Delete")
+ markerMenu.addItem("Coordinates")
+ markerMenu.addItem("Move to")
+ markerMenu.addItem("Draw...")
+
+
+ if (currentMarker == length-2){
+ markerMenu.addItem("Route to next point")
+ markerMenu.addItem("Distance to next point")
+
+ }
+ if (currentMarker < length-2){
+ markerMenu.addItem("Route to next points")
+ markerMenu.addItem("Distance to next point")
+ }
+ map.state = "MarkerPopupMenu"
+ }
+
+
+ function drawItemPopup(){
+ var array
+ var length = map.markers.length
+
+ drawMenu.clear()
+
+ drawMenu.addItem("Image")
+ drawMenu.addItem("Video")
+ drawMenu.addItem("3D QML Item")
+
+ if (currentMarker <= length-2){
+ drawMenu.addItem("Rectangle")
+ drawMenu.addItem("Circle")
+ drawMenu.addItem("Polyline")
+ }
+ if (currentMarker < length-2){
+ drawMenu.addItem("Polygon")
+ }
+ map.state = "DrawItemMenu"
+ }
+
+ function calculateRoute(){
+ routeQuery.clearWaypoints();
+ for (var i = currentMarker; i< map.markers.length; i++){
+ routeQuery.addWaypoint(markers[i].coordinate)
+ }
+ routeQuery.travelModes = RouteQuery.CarTravel
+ routeQuery.routeOptimizations = RouteQuery.ShortestRoute
+ routeQuery.setFeatureWeight(0, 0)
+ routeModel.update();
+ }
+
+ function roundNumber(number, digits) {
+ var multiple = Math.pow(10, digits);
+ return Math.round(number * multiple) / multiple;
+ }
+
+ function formatTime(sec){
+ var value = sec
+ var seconds = value % 60
+ value /= 60
+ value = (value > 1) ? Math.round(value) : 0
+ var minutes = value % 60
+ value /= 60
+ value = (value > 1) ? Math.round(value) : 0
+ var hours = value
+ if (hours > 0) value = hours + "h:"+ minutes + "m"
+ else value = minutes + "min"
+ return value
+ }
+
+ function formatDistance(meters)
+ {
+ var dist = Math.round(meters)
+ if (dist > 1000 ){
+ if (dist > 100000){
+ dist = Math.round(dist / 1000)
+ }
+ else{
+ dist = Math.round(dist / 100)
+ dist = dist / 10
+ }
+ dist = dist + " km"
+ }
+ else{
+ dist = dist + " m"
+ }
+ return dist
+ }
+
+ function setLanguage(lang) {
+ map.plugin.locales = lang;
+ if (map.plugin.locales.length > 0) {
+ languageButton.text = map.plugin.locales[0];
+ }
+ }
+
+ // states of map
+ states: [
+ State {
+ name: "PopupMenu"
+ PropertyChanges { target: popupMenu; opacity: 1}
+ PropertyChanges { target: popupMenu; x: ((map.lastX + popupMenu.width > map.width) ? map.width - popupMenu.width : map.lastX)}
+ PropertyChanges { target: popupMenu; y: ((map.lastY + popupMenu.height > map.height - 40) ? map.height - popupMenu.height - 40 : map.lastY)}
+ },
+ State {
+ name: "MarkerPopupMenu"
+ PropertyChanges { target: markerMenu; opacity: 1}
+ PropertyChanges { target: markerMenu; x: ((markers[currentMarker].lastMouseX + markerMenu.width > map.width) ? map.width - markerMenu.width : markers[currentMarker].lastMouseX )}
+ PropertyChanges { target: markerMenu; y: ((markers[currentMarker].lastMouseY + markerMenu.height > map.height - 40) ? map.height - markerMenu.height - 40 : markers[currentMarker].lastMouseY)}
+ },
+ State {
+ name: "DrawItemMenu"
+ PropertyChanges { target: drawMenu; opacity: 1}
+ PropertyChanges { target: drawMenu; x: ((markers[currentMarker].lastMouseX + drawMenu.width > map.width) ? map.width - drawMenu.width : markers[currentMarker].lastMouseX )}
+ PropertyChanges { target: drawMenu; y: ((markers[currentMarker].lastMouseY + drawMenu.height > map.height - 40) ? map.height - drawMenu.height - 40 : markers[currentMarker].lastMouseY)}
+ },
+ State {
+ name: "RoutePopupMenu"
+ PropertyChanges { target: routeMenu; opacity: 1}
+ PropertyChanges { target: routeMenu; x: ((map.lastX + routeMenu.width > map.width) ? map.width - routeMenu.width : map.lastX)}
+ PropertyChanges { target: routeMenu; y: ((map.lastY + routeMenu.height > map.height - 40) ? map.height - routeMenu.height - 40 : map.lastY)}
+ },
+ State {
+ name: "PointPopupMenu"
+ PropertyChanges { target: pointMenu; opacity: 1}
+ PropertyChanges { target: pointMenu; x: ((map.lastX + pointMenu.width > map.width) ? map.width - pointMenu.width : map.lastX)}
+ PropertyChanges { target: pointMenu; y: ((map.lastY + pointMenu.height > map.height - 40) ? map.height - pointMenu.height - 40 : map.lastY)}
+ },
+ State {
+ name: "LanguageMenu"
+ PropertyChanges { target: languageMenu; opacity: 1}
+ }
+ ]
+//! [end]
+}
+//! [end]
diff --git a/examples/location/mapviewer/content/map/Marker.qml b/examples/location/mapviewer/content/map/Marker.qml
new file mode 100644
index 00000000..d7a1e838
--- /dev/null
+++ b/examples/location/mapviewer/content/map/Marker.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0;
+import QtLocation 5.0
+import QtLocation.examples 5.0
+
+//! [mqi-top]
+MapQuickItem {
+ id: marker
+//! [mqi-top]
+ property alias lastMouseX: markerMouseArea.lastX
+ property alias lastMouseY: markerMouseArea.lastY
+
+//! [mqi-anchor]
+ anchorPoint.x: image.width/4
+ anchorPoint.y: image.height
+
+ sourceItem: Image {
+ id: image
+//! [mqi-anchor]
+ source: markerMouseArea.containsMouse ? (markerMouseArea.pressed ? "../../resources/marker_selected.png" :"../../resources/marker_hovered.png") : "../../resources/marker.png"
+ MapMouseArea {
+ id: markerMouseArea
+ property int pressX : -1
+ property int pressY : -1
+ property int jitterThreshold : 10
+ property int lastX: -1
+ property int lastY: -1
+ anchors.fill: parent
+ hoverEnabled : false
+ drag.target: marker
+
+ onPressed : {
+ map.pressX = mouse.x
+ map.pressY = mouse.y
+ map.currentMarker = -1
+ for (var i = 0; i< map.markers.length; i++){
+ if (marker == map.markers[i]){
+ map.currentMarker = i
+ break
+ }
+ }
+ map.state = ""
+ }
+
+ onPressAndHold:{
+ if (Math.abs(map.pressX - mouse.x ) < map.jitterThreshold
+ && Math.abs(map.pressY - mouse.y ) < map.jitterThreshold) {
+ lastX = map.toScreenPosition(marker.coordinate).x
+ lastY = map.toScreenPosition(marker.coordinate).y
+ map.markerPopup()
+ }
+ }
+ }
+
+ Text{
+ id: number
+ y: image.height/4
+ color: "white"
+ font.bold: true
+ font.pixelSize: 14
+ width:27
+ horizontalAlignment: Text.AlignHCenter
+ Component.onCompleted: {
+ text = map.markerCounter
+ }
+ }
+
+//! [mqi-closeimage]
+ }
+//! [mqi-closeimage]
+
+ Component.onCompleted: coordinate = mouseArea.lastCoordinate
+//! [mqi-close]
+}
+//! [mqi-close]
diff --git a/examples/location/mapviewer/content/map/MiniMap.qml b/examples/location/mapviewer/content/map/MiniMap.qml
new file mode 100644
index 00000000..e5d03e49
--- /dev/null
+++ b/examples/location/mapviewer/content/map/MiniMap.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+
+Rectangle{
+ id: miniMapRect
+ width: 152
+ height: 152
+ anchors.right: (parent) ? parent.right : undefined
+ anchors.rightMargin: 10
+ anchors.top: (parent) ? parent.top : undefined
+ anchors.topMargin: 10
+ color: "#242424"
+ Map {
+ id: miniMap
+ anchors.top: parent.top
+ anchors.topMargin: 1
+ anchors.left: parent.left
+ anchors.leftMargin: 1
+ width: 150
+ height: 150
+ zoomLevel: (map.zoomLevel > minimumZoomLevel + 3) ? minimumZoomLevel + 3 : 2.5
+ center: map.center
+ plugin: map.plugin
+ gesture.enabled: false
+ MapMouseArea{
+ anchors.fill: parent
+ }
+
+ MapRectangle {
+ color: "#44ff0000"
+ border.width: 1
+ border.color: "red"
+ topLeft {
+ latitude: miniMap.center.latitude + 5
+ longitude: miniMap.center.longitude - 5
+ }
+ bottomRight {
+ latitude: miniMap.center.latitude - 5
+ longitude: miniMap.center.longitude + 5
+ }
+ }
+ }
+}
diff --git a/examples/location/mapviewer/content/map/PolygonItem.qml b/examples/location/mapviewer/content/map/PolygonItem.qml
new file mode 100644
index 00000000..b6e41ea6
--- /dev/null
+++ b/examples/location/mapviewer/content/map/PolygonItem.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+
+//TODO: remove me when items are integrated
+
+MapPolygon {
+
+ color: "green"
+ border.color: "darkgreen"
+ border.width: 4
+ smooth: true
+ opacity: 0.5
+
+ function setGeometry(markers, index){
+ for (var i = index; i<markers.length; i++){
+ addCoordinate(markers[i].coordinate)
+ }
+ }
+ MapMouseArea {
+ anchors.fill:parent
+ id: mousearea
+ drag.target: parent
+ }
+}
diff --git a/examples/location/mapviewer/content/map/PolylineItem.qml b/examples/location/mapviewer/content/map/PolylineItem.qml
new file mode 100644
index 00000000..f065142e
--- /dev/null
+++ b/examples/location/mapviewer/content/map/PolylineItem.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+
+//TODO: remove/refactor me when items are integrated
+
+MapPolyline {
+ line.color: "blue"
+ line.width: 4
+ opacity: 0.7
+ smooth: true
+
+ function setGeometry(markers, index){
+ for (var i = index; i<markers.length; i++){
+ addCoordinate(markers[i].coordinate)
+ }
+ }
+}
diff --git a/examples/location/mapviewer/content/map/RectangleItem.qml b/examples/location/mapviewer/content/map/RectangleItem.qml
new file mode 100644
index 00000000..97896883
--- /dev/null
+++ b/examples/location/mapviewer/content/map/RectangleItem.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+
+MapRectangle {
+ id: mapRectangle
+
+ color: mousearea.containsMouse ? "lime" : "red"
+ opacity: 0.5
+ border.width: 2.0
+
+ function setGeometry(markers, index){
+ topLeft.latitude = Math.max(markers[index].coordinate.latitude, markers[index + 1].coordinate.latitude)
+ topLeft.longitude = Math.min(markers[index].coordinate.longitude, markers[index + 1].coordinate.longitude)
+ bottomRight.latitude = Math.min(markers[index].coordinate.latitude, markers[index + 1].coordinate.latitude)
+ bottomRight.longitude = Math.max(markers[index].coordinate.longitude, markers[index + 1].coordinate.longitude)
+ }
+
+ Binding {
+ target: mapRectangle
+ property: 'border.width'
+ value: 60
+
+ when: ((topLeft.latitude == -27.1144) &&
+ (topLeft.longitude == 152.6594) &&
+ (bottomRight.latitude == -27.7434) &&
+ (bottomRight.longitude == 153.3021))
+ }
+
+ MapMouseArea {
+ anchors.fill:parent
+ id: mousearea
+ hoverEnabled: false
+ drag.target: parent
+ }
+}
diff --git a/examples/location/mapviewer/content/map/VideoItem.qml b/examples/location/mapviewer/content/map/VideoItem.qml
new file mode 100644
index 00000000..a3df3c99
--- /dev/null
+++ b/examples/location/mapviewer/content/map/VideoItem.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0;
+import QtLocation 5.0
+import QtMultimedia 5.0
+
+// NOTE: If the creation of this compoment fails, make sure you have the latest
+// qtmultimedia and relevant gstreamer etc packages installed.
+// You can test your system with qtmultimedia examples.
+MapQuickItem { //to be used inside MapComponent only
+ id: testVideoItem
+
+ // zoomLevel: 8 // set this if you want the video to follow zoom level changes
+
+ function setGeometry(markers, index) {
+ coordinate.latitude = markers[index].coordinate.latitude
+ coordinate.longitude = markers[index].coordinate.longitude
+ }
+
+ sourceItem: Rectangle {
+ id: testVideo
+ color: "black"
+ x: 0;
+ y: 0;
+ z: 500
+ width: 176;
+ height: 144;
+ MediaPlayer {
+ id: player
+ source: "file://" + appDirPath + "/demo.ogv"
+ autoPlay: true
+
+ onError: {
+ if (MediaPlayer.NoError != error) {
+ console.log(errorString)
+ }
+ }
+ }
+ VideoOutput {
+ id: videoItem
+ source: player
+ anchors.fill: parent
+ }
+ MouseArea{
+ anchors.fill: parent
+ onClicked: {
+ if (player.playbackState == MediaPlayer.PlayingState)
+ player.stop()
+ else
+ player.play()
+ }
+ }
+ }
+}
diff --git a/examples/location/mapviewer/demo.ogv b/examples/location/mapviewer/demo.ogv
new file mode 100644
index 00000000..1ed7e540
--- /dev/null
+++ b/examples/location/mapviewer/demo.ogv
Binary files differ
diff --git a/examples/location/mapviewer/icon.png b/examples/location/mapviewer/icon.png
new file mode 100644
index 00000000..0954baf0
--- /dev/null
+++ b/examples/location/mapviewer/icon.png
Binary files differ
diff --git a/examples/location/mapviewer/mapviewer.pro b/examples/location/mapviewer/mapviewer.pro
new file mode 100644
index 00000000..7ae7b4dc
--- /dev/null
+++ b/examples/location/mapviewer/mapviewer.pro
@@ -0,0 +1,49 @@
+TARGET = qml_location_mapviewer
+TEMPLATE = app
+
+QT += qml network quick
+SOURCES += qmlmapviewerwrapper.cpp
+
+RESOURCES += \
+ mapviewerwrapper.qrc
+
+qmlcontent.files += \
+ mapviewer.qml \
+ demo.ogv
+OTHER_FILES += $$qmlcontent.files
+
+qmlcontentmap.files += \
+ content/map/MapComponent.qml \
+ content/map/Marker.qml \
+ content/map/CircleItem.qml \
+ content/map/RectangleItem.qml \
+ content/map/PolylineItem.qml \
+ content/map/PolygonItem.qml \
+ content/map/ImageItem.qml \
+ content/map/VideoItem.qml \
+ content/map/3dItem.qml \
+ content/map/MiniMap.qml
+OTHER_FILES += $$qmlcontentmap.files
+
+qmlcontentdialogs.files += \
+ content/dialogs/Message.qml \
+ content/dialogs/RouteDialog.qml
+OTHER_FILES += $$qmlcontentdialogs.files
+
+include(../common/common.pri)
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtlocation/declarative/mapviewer
+
+INSTALLS += target
+
+!equals($${_PRO_FILE_PWD_}, $${OUT_PWD}) {
+ MEDIAFILE = $${_PRO_FILE_PWD_}/demo.ogv
+ copy2build.input = MEDIAFILE
+ copy2build.output = $${OUT_PWD}/demo.ogv
+ !contains(TEMPLATE_PREFIX, vc):copy2build.variable_out = PRE_TARGETDEPS
+ copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+ copy2build.name = COPY ${QMAKE_FILE_IN}
+ copy2build.CONFIG += no_link
+ copy2build.CONFIG += no_clean
+ QMAKE_EXTRA_COMPILERS += copy2build
+}
diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml
new file mode 100644
index 00000000..59a5de5c
--- /dev/null
+++ b/examples/location/mapviewer/mapviewer.qml
@@ -0,0 +1,722 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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 QtQuick 2.0
+import QtLocation 5.0
+import QtPositioning 5.2
+import QtLocation.examples 5.0
+import "content/map"
+import "content/dialogs"
+
+Item {
+ id: page
+ width: parent ? parent.width : 360
+ height: parent ? parent.height : 640
+ property variant map
+ property variant minimap
+ property variant parameters
+
+ Rectangle {
+ id: backgroundRect
+ anchors.fill: parent
+ color: "lightgrey"
+ z:2
+ }
+
+ //=====================Menu=====================
+ Menu {
+ id:mainMenu
+ anchors.bottom: parent.bottom
+ z: backgroundRect.z + 3
+
+ Component.onCompleted: {
+ addItem("Tools")
+ addItem("Map Type")
+ addItem("Provider")
+ }
+
+ onClicked: {
+ switch (button) {
+ case "Tools": {
+ page.state = "Tools"
+ break;
+ }
+ case "Map Type": {
+ page.state = "MapType"
+ break;
+ }
+ case "Provider": {
+ page.state = "Provider"
+ break;
+ }
+ }
+ }
+ }
+
+ Menu {
+ id: toolsMenu
+ z: backgroundRect.z + 2
+ y: page.height
+ horizontalOrientation: false
+
+ onClicked: {
+ switch (button) {
+ case "Reverse geocode": {
+ page.state = "RevGeocode"
+ break;
+ }
+ case "Geocode": {
+ page.state = "Geocode"
+ break;
+ }
+ case "Route": {
+ page.state = "Route"
+ break;
+ }
+ case "Follow me": {
+ map.followme =true
+ page.state = ""
+ break;
+ }
+ case "Stop following": {
+ map.followme =false
+ page.state = ""
+ break;
+ }
+ case "Minimap": {
+ minimap = Qt.createQmlObject ('import "content/map"; MiniMap{ z: map.z + 2 }', map)
+ page.state = ""
+ break;
+ }
+ case "Hide minimap": {
+ if (minimap) minimap.destroy()
+ minimap = null
+ page.state = ""
+ break;
+ }
+ }
+ }
+ function update(){
+ clear()
+ addItem("Reverse geocode")
+ addItem("Geocode")
+ addItem("Route")
+ var item = addItem("Follow me")
+ item.text = Qt.binding(function() { return map.followme ? "Stop following" : "Follow me" });
+ item = addItem("Minimap")
+ item.text = Qt.binding(function() { return minimap ? "Hide minimap" : "Minimap" });
+ }
+ }
+
+ Menu {
+ id: mapTypeMenu
+ z: backgroundRect.z + 2
+ y: page.height
+ horizontalOrientation: false
+ exclusive: true
+
+ onClicked: {
+ page.state = ""
+ }
+
+ onExclusiveButtonChanged: {
+ for (var i = 0; i<map.supportedMapTypes.length; i++){
+ if (exclusiveButton == map.supportedMapTypes[i].name){
+ map.activeMapType = map.supportedMapTypes[i]
+ break;
+ }
+ }
+ }
+
+ function update(){
+ clear()
+ for (var i = 0; i<map.supportedMapTypes.length; i++)
+ addItem(map.supportedMapTypes[i].name)
+
+ if (map.supportedMapTypes.length > 0)
+ exclusiveButton = map.activeMapType.name
+ }
+ }
+
+ Menu {
+ id: providerMenu
+ z: backgroundRect.z + 2
+ y: page.height
+ horizontalOrientation: false
+ exclusive: true
+
+ Component.onCompleted: {
+ var plugins = getPlugins()
+ for (var i = 0; i<plugins.length; i++)
+ addItem(plugins[i])
+ }
+
+ onClicked: {
+ page.state = ""
+ }
+
+ onExclusiveButtonChanged: createMap(exclusiveButton)
+ }
+
+ //=====================Dialogs=====================
+ Message {
+ id: messageDialog
+ z: backgroundRect.z + 2
+ onOkButtonClicked: {
+ page.state = ""
+ }
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+
+ states: [
+ State{
+ name: "GeocodeError"
+ PropertyChanges { target: messageDialog; title: "Geocode Error" }
+ PropertyChanges { target: messageDialog; text: "No data available for the specified location" }
+ },
+ State{
+ name: "UnknownGeocodeError"
+ PropertyChanges { target: messageDialog; title: "Geocode Error" }
+ PropertyChanges { target: messageDialog; text: "Unsuccessful geocode" }
+ },
+ State{
+ name: "AmbiguousGeocode"
+ PropertyChanges { target: messageDialog; title: "Ambiguous geocode" }
+ PropertyChanges { target: messageDialog; text: map.geocodeModel.count + " results found for the given address, please specify location" }
+ },
+ State{
+ name: "RouteError"
+ PropertyChanges { target: messageDialog; title: "Route Error" }
+ PropertyChanges { target: messageDialog; text: "Unable to find a route for the given points"}
+ },
+ State{
+ name: "Coordinates"
+ PropertyChanges { target: messageDialog; title: "Coordinates" }
+ },
+ State{
+ name: "LocationInfo"
+ PropertyChanges { target: messageDialog; title: "Location" }
+ PropertyChanges { target: messageDialog; text: geocodeMessage() }
+ },
+ State{
+ name: "Distance"
+ PropertyChanges { target: messageDialog; title: "Distance" }
+ }
+ ]
+ }
+
+ //Route Dialog
+//! [routedialog0]
+ RouteDialog {
+ id: routeDialog
+
+ property variant startCoordinate
+ property variant endCoordinate
+
+//! [routedialog0]
+ Address { id: startAddress }
+ Address { id: endAddress }
+
+ z: backgroundRect.z + 2
+
+ GeocodeModel {
+ id: tempGeocodeModel
+
+ property int success: 0
+
+ onCountChanged: {
+ if (success == 1 && count == 1) {
+ query = endAddress
+ update();
+ }
+ }
+
+ onStatusChanged: {
+ if ((status == GeocodeModel.Ready) && (count == 1)) {
+ success++
+ if (success == 1){
+ startCoordinate.latitude = get(0).coordinate.latitude
+ startCoordinate.longitude = get(0).coordinate.longitude
+ }
+ if (success == 2) {
+ endCoordinate.latitude = get(0).coordinate.latitude
+ endCoordinate.longitude = get(0).coordinate.longitude
+ success = 0
+ routeDialog.calculateRoute()
+ }
+ }
+ else if ((status == GeocodeModel.Ready) || (status == GeocodeModel.Error)){
+ var st = (success == 0 ) ? "start" : "end"
+ messageDialog.state = ""
+ if ((status == GeocodeModel.Ready) && (count == 0 )) messageDialog.state = "UnknownGeocodeError"
+ else if (status == GeocodeModel.Error) {
+ messageDialog.state = "GeocodeError"
+ messageDialog.text = "Unable to find location for the " + st + " point"
+ }
+ else if ((status == GeocodeModel.Ready) && (count > 1 )){
+ messageDialog.state = "AmbiguousGeocode"
+ messageDialog.text = count + " results found for the " + st + " point, please specify location"
+ }
+ success = 0
+ page.state = "Message"
+ map.routeModel.clearAll()
+ }
+ }
+ }
+
+ onGoButtonClicked: {
+ tempGeocodeModel.reset()
+ messageDialog.state = ""
+ if (routeDialog.byCoordinates) {
+ startCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.startLatitude),
+ parseFloat(routeDialog.startLongitude));
+ endCoordinate = QtPositioning.coordinate(parseFloat(routeDialog.endLatitude),
+ parseFloat(routeDialog.endLongitude));
+
+ calculateRoute()
+ }
+ else {
+ startAddress.country = routeDialog.startCountry
+ startAddress.street = routeDialog.startStreet
+ startAddress.city = routeDialog.startCity
+
+ endAddress.country = routeDialog.endCountry
+ endAddress.street = routeDialog.endStreet
+ endAddress.city = routeDialog.endCity
+
+ tempGeocodeModel.query = startAddress
+ tempGeocodeModel.update();
+ }
+ page.state = ""
+ }
+
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+
+//! [routerequest0]
+ function calculateRoute() {
+ // clear away any old data in the query
+ map.routeQuery.clearWaypoints();
+
+ // add the start and end coords as waypoints on the route
+ map.routeQuery.addWaypoint(startCoordinate)
+ map.routeQuery.addWaypoint(endCoordinate)
+ map.routeQuery.travelModes = routeDialog.travelMode
+ map.routeQuery.routeOptimizations = routeDialog.routeOptimization
+//! [routerequest0]
+
+//! [routerequest0 feature weight]
+ for (var i=0; i<9; i++) {
+ map.routeQuery.setFeatureWeight(i, 0)
+ }
+
+ for (var i=0; i<routeDialog.features.length; i++) {
+ map.routeQuery.setFeatureWeight(routeDialog.features[i], RouteQuery.AvoidFeatureWeight)
+ }
+//! [routerequest0 feature weight]
+
+//! [routerequest1]
+ map.routeModel.update();
+
+ // center the map on the start coord
+ map.center = startCoordinate;
+//! [routerequest1]
+ }
+//! [routedialog1]
+ }
+//! [routedialog1]
+
+ //Geocode Dialog
+//! [geocode0]
+ InputDialog {
+ id: geocodeDialog
+//! [geocode0]
+ title: "Geocode"
+ z: backgroundRect.z + 2
+
+ Component.onCompleted: {
+ var obj = [["Street", "Brandl St"],["City", "Eight Mile Plains"],["State", ""],["Country","Australia"], ["Postal code", ""]]
+ setModel(obj)
+ }
+
+//! [geocode1]
+ Address {
+ id: geocodeAddress
+ }
+
+ onGoButtonClicked: {
+ // manage the UI state transitions
+ page.state = ""
+ messageDialog.state = ""
+
+ // fill out the Address element
+ geocodeAddress.street = dialogModel.get(0).inputText
+ geocodeAddress.city = dialogModel.get(1).inputText
+ geocodeAddress.state = dialogModel.get(2).inputText
+ geocodeAddress.country = dialogModel.get(3).inputText
+ geocodeAddress.postalCode = dialogModel.get(4).inputText
+
+ // send the geocode request
+ map.geocodeModel.query = geocodeAddress
+ map.geocodeModel.update()
+ }
+//! [geocode1]
+
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+//! [geocode2]
+ }
+//! [geocode2]
+
+ //Reverse Geocode Dialog
+ InputDialog {
+ id: reverseGeocodeDialog
+ title: "Reverse Geocode"
+ z: backgroundRect.z + 2
+
+ Component.onCompleted: {
+ var obj = [["Latitude","-27.575"],["Longitude", "153.088"]]
+ setModel(obj)
+ }
+
+ onGoButtonClicked: {
+ page.state = ""
+ messageDialog.state = ""
+ map.geocodeModel.query = QtPositioning.coordinate(parseFloat(dialogModel.get(0).inputText),
+ parseFloat(dialogModel.get(1).inputText));
+ map.geocodeModel.update();
+ }
+
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+ }
+
+ //Get new coordinates for marker
+ InputDialog {
+ id: coordinatesDialog
+ title: "New coordinates"
+ z: backgroundRect.z + 2
+
+ Component.onCompleted: {
+ var obj = [["Latitude", ""],["Longitude", ""]]
+ setModel(obj)
+ }
+
+ onGoButtonClicked: {
+ page.state = ""
+ messageDialog.state = ""
+ var newLat = parseFloat(dialogModel.get(0).inputText)
+ var newLong = parseFloat(dialogModel.get(1).inputText)
+
+ if (newLat !== "NaN" && newLong !== "NaN") {
+ var c = QtPositioning.coordinate(newLat, newLong);
+ if (c.isValid) {
+ map.markers[map.currentMarker].coordinate = c;
+ map.center = c;
+ }
+ }
+ }
+
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+ }
+
+ //Get new locale
+ InputDialog {
+ id: localeDialog
+ title: "New Locale"
+ z: backgroundRect.z + 2
+
+ Component.onCompleted: {
+ var obj = [["Language", ""]]
+ setModel(obj)
+ }
+
+ onGoButtonClicked: {
+ page.state = ""
+ messageDialog.state = ""
+ map.setLanguage(dialogModel.get(0).inputText.split(Qt.locale().groupSeparator));
+ }
+
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+ }
+
+
+ /* GeocodeModel {
+ id: geocodeModel
+ plugin : Plugin { name : "nokia"}
+ onLocationsChanged: {
+ if (geocodeModel.count > 0) {
+ console.log('setting the coordinate as locations changed in model.')
+ map.center = geocodeModel.get(0).coordinate
+ }
+ }
+ }*/
+
+ //=====================Map=====================
+
+ /* MapObjectView {
+ model: geocodeModel
+ delegate: Component {
+ MapCircle {
+ radius: 10000
+ color: "red"
+ center: location.coordinate
+ }
+ }
+ }
+
+
+ */
+
+/*
+
+ }
+*/
+ function geocodeMessage(){
+ var street, district, city, county, state, countryCode, country, postalCode, latitude, longitude, text
+ latitude = Math.round(map.geocodeModel.get(0).coordinate.latitude * 10000) / 10000
+ longitude =Math.round(map.geocodeModel.get(0).coordinate.longitude * 10000) / 10000
+ street = map.geocodeModel.get(0).address.street
+ district = map.geocodeModel.get(0).address.district
+ city = map.geocodeModel.get(0).address.city
+ county = map.geocodeModel.get(0).address.county
+ state = map.geocodeModel.get(0).address.state
+ countryCode = map.geocodeModel.get(0).address.countryCode
+ country = map.geocodeModel.get(0).address.country
+ postalCode = map.geocodeModel.get(0).address.postalCode
+
+ text = "<b>Latitude:</b> " + latitude + "<br/>"
+ text +="<b>Longitude:</b> " + longitude + "<br/>" + "<br/>"
+ if (street) text +="<b>Street: </b>"+ street + " <br/>"
+ if (district) text +="<b>District: </b>"+ district +" <br/>"
+ if (city) text +="<b>City: </b>"+ city + " <br/>"
+ if (county) text +="<b>County: </b>"+ county + " <br/>"
+ if (state) text +="<b>State: </b>"+ state + " <br/>"
+ if (countryCode) text +="<b>Country code: </b>"+ countryCode + " <br/>"
+ if (country) text +="<b>Country: </b>"+ country + " <br/>"
+ if (postalCode) text +="<b>PostalCode: </b>"+ postalCode + " <br/>"
+ return text
+ }
+
+ function createMap(provider){
+ var plugin
+ if (parameters.length>0)
+ plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin{ name:"' + provider + '"; parameters: page.parameters}', page)
+ else
+ plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin{ name:"' + provider + '"}', page)
+ if (plugin.supportsMapping()
+ && plugin.supportsGeocoding(Plugin.ReverseGeocodingFeature)
+ && plugin.supportsRouting()) {
+
+ if (map) {
+ map.destroy()
+ minimap = null
+ }
+
+ map = Qt.createQmlObject ('import QtLocation 5.0;\
+ import "content/map";\
+ MapComponent{\
+ z : backgroundRect.z + 1;\
+ width: page.width;\
+ height: page.height - mainMenu.height;\
+ onFollowmeChanged: {toolsMenu.update()}\
+ onSupportedMapTypesChanged: {mapTypeMenu.update()}\
+ onCoordinatesCaptured: {\
+ messageDialog.state = "Coordinates";\
+ messageDialog.text = "<b>Latitude:</b> " + roundNumber(latitude,4) + "<br/><b>Longitude:</b> " + roundNumber(longitude,4);\
+ page.state = "Message";\
+ }\
+ onGeocodeFinished:{\
+ 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";\
+ }\
+ onShowDistance:{\
+ messageDialog.state = "Distance";\
+ messageDialog.text = "<b>Distance:</b> " + distance;\
+ page.state = "Message";\
+ }\
+ onMoveMarker: {\
+ page.state = "Coordinates";\
+ }\
+ onRouteError: {\
+ messageDialog.state = "RouteError";\
+ page.state = "Message";\
+ }\
+ onRequestLocale:{\
+ page.state = "Locale";\
+ }\
+ onShowGeocodeInfo:{\
+ messageDialog.state = "LocationInfo";\
+ page.state = "Message";\
+ }\
+ onResetState: {\
+ page.state = "";\
+ }\
+ }',page)
+ map.plugin = plugin;
+ tempGeocodeModel.plugin = plugin;
+ mapTypeMenu.update();
+ toolsMenu.update();
+ }
+ }
+
+ function getPlugins(){
+ var plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {}', page)
+ var tempPlugin
+ var myArray = new Array()
+ for (var i = 0; i<plugin.availableServiceProviders.length; i++){
+ tempPlugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', page)
+
+ if (tempPlugin.supportsMapping()
+ && tempPlugin.supportsGeocoding(Plugin.ReverseGeocodingFeature)
+ && tempPlugin.supportsRouting()) {
+ myArray.push(tempPlugin.name)
+ }
+ }
+
+ return myArray
+ }
+
+ function setPluginParameters(pluginParameters) {
+ var parameters = new Array()
+ for (var prop in pluginParameters){
+ var parameter = Qt.createQmlObject('import QtLocation 5.0; PluginParameter{ name: "'+ prop + '"; value: "' + pluginParameters[prop]+'"}',page)
+ parameters.push(parameter)
+ }
+ page.parameters=parameters
+ if (providerMenu.exclusiveButton !== "")
+ createMap(providerMenu.exclusiveButton);
+ else if (providerMenu.children.length > 0)
+ createMap(providerMenu.children[0].text);
+ }
+
+ //=====================States of page=====================
+ states: [
+ State {
+ name: "RevGeocode"
+ PropertyChanges { target: reverseGeocodeDialog; opacity: 1 }
+ },
+ State {
+ name: "Route"
+ PropertyChanges { target: routeDialog; opacity: 1 }
+ },
+ State {
+ name: "Geocode"
+ PropertyChanges { target: geocodeDialog; opacity: 1 }
+ },
+ State {
+ name: "Coordinates"
+ PropertyChanges { target: coordinatesDialog; opacity: 1 }
+ },
+ State {
+ name: "Message"
+ PropertyChanges { target: messageDialog; opacity: 1 }
+ },
+ State {
+ name : "Tools"
+ PropertyChanges { target: toolsMenu; y: page.height - toolsMenu.height - mainMenu.height }
+ },
+ State {
+ name : "Provider"
+ PropertyChanges { target: providerMenu; y: page.height - providerMenu.height - mainMenu.height }
+ },
+ State {
+ name : "MapType"
+ PropertyChanges { target: mapTypeMenu; y: page.height - mapTypeMenu.height - mainMenu.height }
+ },
+ State {
+ name : "Locale"
+ PropertyChanges { target: localeDialog; opacity: 1 }
+ }
+ ]
+
+ //=====================State-transition animations for page=====================
+ transitions: [
+ Transition {
+ to: "RevGeocode"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Route"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Geocode"
+ 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 }
+ },
+ Transition {
+ to: ""
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Provider"
+ NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "MapType"
+ NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Tools"
+ NumberAnimation { properties: "y" ; duration: 300; easing.type: Easing.Linear }
+ }
+ ]
+}
diff --git a/examples/location/mapviewer/mapviewerwrapper.qrc b/examples/location/mapviewer/mapviewerwrapper.qrc
new file mode 100644
index 00000000..854a6503
--- /dev/null
+++ b/examples/location/mapviewer/mapviewerwrapper.qrc
@@ -0,0 +1,19 @@
+<RCC>
+ <qresource prefix="/">
+ <file>mapviewer.qml</file>
+ <file>icon.png</file>
+ <file>content/map/MapComponent.qml</file>
+ <file>content/map/Marker.qml</file>
+ <file>content/map/PolylineItem.qml</file>
+ <file>content/map/RectangleItem.qml</file>
+ <file>content/map/CircleItem.qml</file>
+ <file>content/map/PolygonItem.qml</file>
+ <file>content/dialogs/Message.qml</file>
+ <file>content/dialogs/RouteDialog.qml</file>
+ <file>content/map/ImageItem.qml</file>
+ <file>content/map/VideoItem.qml</file>
+ <file>content/map/3dItem.qml</file>
+ <file>content/map/MiniMap.qml</file>
+ <file>demo.ogv</file>
+ </qresource>
+</RCC>
diff --git a/examples/location/mapviewer/qmlmapviewerwrapper.cpp b/examples/location/mapviewer/qmlmapviewerwrapper.cpp
new file mode 100644
index 00000000..5f5aee84
--- /dev/null
+++ b/examples/location/mapviewer/qmlmapviewerwrapper.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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 Digia Plc 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$
+**
+****************************************************************************/
+
+#include <QtCore/QStringList>
+#include <QtCore/QTextStream>
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlContext>
+#include <QtQuick/QQuickView>
+#include <QtQuick/QQuickItem>
+
+static bool parseArgs(QStringList& args, QVariantMap& parameters)
+{
+
+ while (!args.isEmpty()) {
+
+ QString param = args.takeFirst();
+
+ if (param.startsWith("--help")) {
+ QTextStream out(stdout);
+ out << "Usage: " << endl;
+ out << "--plugin.<parameter_name> <parameter_value> - Sets parameter = value for plugin" << endl;
+ out.flush();
+ return true;
+ }
+
+ if (param.startsWith("--plugin.")) {
+
+ param.remove(0, 9);
+
+ if (args.isEmpty() || args.first().startsWith("--")) {
+ parameters[param] = true;
+ } else {
+
+ QString value = args.takeFirst();
+
+ if (value == "true" || value == "on" || value == "enabled") {
+ parameters[param] = true;
+ } else if (value == "false" || value == "off"
+ || value == "disable") {
+ parameters[param] = false;
+ } else {
+ parameters[param] = value;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication application(argc, argv);
+
+ QVariantMap parameters;
+ QStringList args(QCoreApplication::arguments());
+
+ if (parseArgs(args, parameters)) exit(0);
+
+ const QString mainQmlApp = QLatin1String("qrc:///mapviewer.qml");
+ QQuickView view;
+
+ view.engine()->addImportPath(QLatin1String(":/imports"));
+
+ view.rootContext()->setContextProperty("appDirPath", QCoreApplication::applicationDirPath());
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+
+ QQuickItem *object = view.rootObject();
+ QMetaObject::invokeMethod(object, "setPluginParameters",
+ Q_ARG(QVariant, QVariant::fromValue(parameters)));
+
+ QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+ view.setGeometry(QRect(100, 100, 360, 640));
+ view.show();
+ return application.exec();
+}