summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2016-06-29 18:22:15 +0200
committerMichal Klocek <michal.klocek@qt.io>2016-07-28 14:09:17 +0000
commit75dd424e11964d8755abdb1b12b27a8479353b37 (patch)
tree3b37b6b04e5bb813c9e0a17ebc314211c3b4b028
parentcd12d3c8eaf1c1a3dabfb50f88c635b9b1def3fc (diff)
downloadqtlocation-75dd424e11964d8755abdb1b12b27a8479353b37.tar.gz
Add minimal map qml example
QtLocation was missnig basic example to show maps, the one you can simply jump in and start hacking. Change-Id: I0aec90ae25aa703d84f7e52e4dd523931819e79c Reviewed-by: Paolo Angelelli <paolo.angelelli@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
-rw-r--r--examples/location/location.pro1
-rw-r--r--examples/location/minimal_map/doc/images/minimal_map.pngbin0 -> 156053 bytes
-rw-r--r--examples/location/minimal_map/doc/src/minimal_map.qdoc89
-rw-r--r--examples/location/minimal_map/main.cpp53
-rw-r--r--examples/location/minimal_map/main.qml67
-rw-r--r--examples/location/minimal_map/minimal_map.pro10
-rw-r--r--examples/location/minimal_map/qml.qrc6
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp32
-rw-r--r--src/location/doc/images/api-map.pngbin62031 -> 0 bytes
9 files changed, 235 insertions, 23 deletions
diff --git a/examples/location/location.pro b/examples/location/location.pro
index 851e37ac..0b4b2338 100644
--- a/examples/location/location.pro
+++ b/examples/location/location.pro
@@ -5,5 +5,6 @@ qtHaveModule(quick) {
places_list \
places_map \
mapviewer \
+ minimal_map \
planespotter
}
diff --git a/examples/location/minimal_map/doc/images/minimal_map.png b/examples/location/minimal_map/doc/images/minimal_map.png
new file mode 100644
index 00000000..31ad0f8b
--- /dev/null
+++ b/examples/location/minimal_map/doc/images/minimal_map.png
Binary files differ
diff --git a/examples/location/minimal_map/doc/src/minimal_map.qdoc b/examples/location/minimal_map/doc/src/minimal_map.qdoc
new file mode 100644
index 00000000..06b310aa
--- /dev/null
+++ b/examples/location/minimal_map/doc/src/minimal_map.qdoc
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example minimal_map
+\title Minimal Map (QML)
+\ingroup qtlocation-examples
+\brief The minimum code to display a map using Qt Quick.
+
+\image minimal_map.png
+
+\e {Minimal Map} demonstrates how to use the \l{Map} item to render a map.
+It shows the minimum amount of code needed to display the map, and can be used
+as a basis for further experimentation.
+
+\include examples-run.qdocinc
+
+\section1 C++ Code
+
+In \c main.cpp we use only the QGuiApplication and QQmlApplicationEngine
+classes.
+
+\quotefromfile minimal_map/main.cpp
+\skipto #include
+\printto main
+
+In the main function, we first instantiate a QGuiApplication object.
+Then we create a QQmlApplicationEngine and tell it to load \c main.qml
+from the \l{The Qt Resource System}{Qt Resource System}.
+
+Finally, QGuiApplication::exec() launches the main event loop.
+
+\printuntil }
+
+\section1 QML Code
+
+In \c main.qml, we import the \l {Qt Location QML Types}{QtLocation} QML module
+and its depending \l {Qt Positioning QML Types}{QtPositioning} QML module.
+Next, we create the top level window, set a sensible default size, and make
+it visible. The window will be filled by a \l [QML]{Map} item showing the map.
+
+\quotefromfile minimal_map/main.qml
+\skipto import
+\printuntil }
+\printline }
+\skipto Map
+\printuntil }
+\printline }
+
+The \l [QML]{Plugin} item is necessary to define the map provider we are
+going to use. The example can work with any of the available geo services
+plugins. However, some plugins may require additional plugin parameters
+in order to function correctly and we can use \l [QML]{PluginParameter}
+to specify them. In this example, we use the \c osm plugin, which is a
+\l {Qt Location Open Street Map Plugin} and does not require any parameters.
+
+In the \l [QML]{Map} item, we refer to the \c plugin we use and we set the \c
+center and the \c zoomLevel of the map.
+
+\section1 Requirements
+
+The example requires a working internet connection to download
+\c OpenStreetMap map tiles. An optional system proxy should be picked
+up automatically.
+*/
diff --git a/examples/location/minimal_map/main.cpp b/examples/location/minimal_map/main.cpp
new file mode 100644
index 00000000..e0b58e38
--- /dev/null
+++ b/examples/location/minimal_map/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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 <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
diff --git a/examples/location/minimal_map/main.qml b/examples/location/minimal_map/main.qml
new file mode 100644
index 00000000..26f24986
--- /dev/null
+++ b/examples/location/minimal_map/main.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** 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 The Qt Company Ltd 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 QtQuick.Window 2.0
+import QtLocation 5.6
+import QtPositioning 5.6
+
+Window {
+ width: 512
+ height: 512
+ visible: true
+
+ Plugin {
+ id: osmPlugin
+ name: "osm"
+ // specify plugin parameters if necessary
+ // PluginParameter {
+ // name:
+ // value:
+ // }
+ }
+
+ Map {
+ anchors.fill: parent
+ plugin: osmPlugin
+ center: QtPositioning.coordinate(59.91, 10.75) // Oslo
+ zoomLevel: 10
+ }
+}
diff --git a/examples/location/minimal_map/minimal_map.pro b/examples/location/minimal_map/minimal_map.pro
new file mode 100644
index 00000000..5c165252
--- /dev/null
+++ b/examples/location/minimal_map/minimal_map.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += location
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/location/minimal_map
+INSTALLS += target
diff --git a/examples/location/minimal_map/qml.qrc b/examples/location/minimal_map/qml.qrc
new file mode 100644
index 00000000..0ff3892d
--- /dev/null
+++ b/examples/location/minimal_map/qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
+
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 082eaf98..b220c899 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -134,31 +134,17 @@ QT_BEGIN_NAMESPACE
\section2 Example Usage
The following snippet shows a simple Map and the necessary Plugin type
- to use it. The map is centered near Brisbane, Australia, zoomed out to the
- minimum zoom level, with gesture interaction enabled.
+ to use it. The map is centered over Oslo, Norway, with zoom level 10.
- \code
- Plugin {
- id: somePlugin
- // code here to choose the plugin as necessary
- }
-
- Map {
- id: map
-
- plugin: somePlugin
-
- center {
- latitude: -27
- longitude: 153
- }
- zoomLevel: map.minimumZoomLevel
-
- gesture.enabled: true
- }
- \endcode
+ \quotefromfile minimal_map/main.qml
+ \skipto import
+ \printuntil }
+ \printline }
+ \skipto Map
+ \printuntil }
+ \printline }
- \image api-map.png
+ \image minimal_map.png
*/
/*!
diff --git a/src/location/doc/images/api-map.png b/src/location/doc/images/api-map.png
deleted file mode 100644
index 6e7255d4..00000000
--- a/src/location/doc/images/api-map.png
+++ /dev/null
Binary files differ