summaryrefslogtreecommitdiff
path: root/examples/location/mapviewer/content
diff options
context:
space:
mode:
Diffstat (limited to 'examples/location/mapviewer/content')
-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
12 files changed, 2419 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()
+ }
+ }
+ }
+}