summaryrefslogtreecommitdiff
path: root/src/location/doc/src/examples/declarative-mapviewer.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/doc/src/examples/declarative-mapviewer.qdoc')
-rw-r--r--src/location/doc/src/examples/declarative-mapviewer.qdoc91
1 files changed, 38 insertions, 53 deletions
diff --git a/src/location/doc/src/examples/declarative-mapviewer.qdoc b/src/location/doc/src/examples/declarative-mapviewer.qdoc
index 7bf95f54..f62f535d 100644
--- a/src/location/doc/src/examples/declarative-mapviewer.qdoc
+++ b/src/location/doc/src/examples/declarative-mapviewer.qdoc
@@ -47,8 +47,8 @@
\endcode
Refer to the documentation for each of the geo services plugins for details on what plugin
- parameters they support. The HERE services plugin supplied with Qt requires an \e app_id and
- \e token pair. See "\l {Qt Location HERE Plugin}" for details.
+ parameters they support. The default plugin used by this example is
+ \l {Qt Location Open Street Map Plugin}, which does not require any parameters.
QML types shown in this example:
@@ -57,7 +57,7 @@
\list
\li \l{QtLocation::Map}{Map}
\li \l{QtLocation::MapGestureArea}{MapGestureArea}
- \li \l{coordinate}
+ \li \l[QML]{Coordinate}
\endlist
\li Finding an address
\list
@@ -79,63 +79,48 @@
Drawing a map on-screen is accomplished using the Map type, as shown
below.
- \snippet mapviewer/content/map/MapComponent.qml top
- \snippet mapviewer/content/map/MapComponent.qml coord
- \snippet mapviewer/content/map/MapComponent.qml end
+ \snippet mapviewer/map/MapComponent.qml top
+ \snippet mapviewer/map/MapComponent.qml coord
+ \snippet mapviewer/map/MapComponent.qml end
- In this example, we give the map an initial center \l {coordinate}
+ In this example, we give the map an initial center \l [QML]{Coordinate}{coordinate}
with a set latitude and longitude. We also set the initial zoom level to 50% (halfway between
the maximum and minimum).
- The calls to "pinch" and "flick" are used to enable gestures on the map.
- The flick gesture is also sometimes known as "kinetic panning", and provides
- a more intuitive feel for panning the map both on touch screens and with
- a mouse.
-
- As we do not specify a plugin for supplying map data, the platform default
- will be used. This is typically the "osm" plugin, which provides data from
- OpenStreetMap services. Additional licensing conditions do apply to the use of this data,
- please see the documentation for further details.
-
\section2 Finding an Address (Geocoding)
To locate a certain address or place on the map uses a process called
geocoding. In order to perform a geocode operation, we first need to adjust
our Map object to be able to receive the result.
- Receiving results of geocoding is done through a GeocodeModel, which is
- typically instantiated as a property of the Map component:
+ Receiving results of geocoding is done through a GeocodeModel:
- \snippet mapviewer/content/map/MapComponent.qml geocodemodel0
- \snippet mapviewer/content/map/MapComponent.qml geocodemodel1
+ \snippet mapviewer/map/MapComponent.qml geocodemodel0
- Then, to display the contents of the GeocodeModel we use a MapItemView:
+ To display the contents of the GeocodeModel we use a MapItemView:
- \snippet mapviewer/content/map/MapComponent.qml geocodeview
+ \snippet mapviewer/map/MapComponent.qml geocodeview
MapItemView uses an object called a "delegate" to act as a template for the
items it creates. This can contain any map object desired, but in this case
we show a MapCircle:
- \snippet mapviewer/content/map/MapComponent.qml pointdel0
- \snippet mapviewer/content/map/MapComponent.qml pointdel1
+ \snippet mapviewer/map/MapComponent.qml pointdel0
+ \snippet mapviewer/map/MapComponent.qml pointdel1
With these three objects, we have enough to receive Geocode responses and
display them on our Map. The final piece is to send the actual Geocode
request.
- In this example, we have a utility component called Dialog which we use
- to display the user interface requesting geocoding parameters. You can
- create a similar component yourself using Dialog.qml in this example
- as a reference, or drive the process using any other UI you wish.
-
- To send a geocode request, first we create an Address object, and fill it
- in with the desired parameters. Then we set "map.geocodeModel.query" to
- the filled in Address, and call update() on the GeocodeModel.
+ To send a geocode request, first we create an \l [QML]{Address} object, and fill it
+ in with the desired parameters.
\snippet mapviewer/mapviewer.qml geocode0
- \snippet mapviewer/mapviewer.qml geocode1
- \snippet mapviewer/mapviewer.qml geocode2
+
+ Then we set "geocodeModel.query" to the filled in \l [QML]{Address},
+ and call update() on the GeocodeModel.
+
+ \snippet mapviewer/map/MapComponent.qml geocode1
\section2 Directions and Travel Routes
@@ -145,49 +130,49 @@
Here again, we instantiate the RouteModel as a property of our Map:
- \snippet mapviewer/content/map/MapComponent.qml routemodel0
- \snippet mapviewer/content/map/MapComponent.qml routemodel3
+ \snippet mapviewer/map/MapComponent.qml routemodel0
To display the contents of a model to the user, we need a view. Once again
we will use a MapItemView, to display the Routes as objects on the Map:
- \snippet mapviewer/content/map/MapComponent.qml routeview
+ \snippet mapviewer/map/MapComponent.qml routeview0
+ \snippet mapviewer/map/MapComponent.qml routeview1
To act as a template for the objects we wish the view to create, we create
a delegate component:
- \snippet mapviewer/content/map/MapComponent.qml routedelegate0
- \snippet mapviewer/content/map/MapComponent.qml routedelegate1
+ \snippet mapviewer/map/MapComponent.qml routedelegate0
+ \snippet mapviewer/map/MapComponent.qml routedelegate1
With the model, view and delegate now complete, the only missing component
is some kind of control over the model to begin the Route request process.
In the simplest case, we can fill out a Route request using two already
- available \l {coordinate}{coordinates}, which we store inside the RouteDialog
- component:
+ available \l [QML]{Coordinate}{coordinates}:
- \snippet mapviewer/mapviewer.qml routedialog0
- \snippet mapviewer/mapviewer.qml routedialog1
+ \snippet mapviewer/mapviewer.qml routecoordinate
In the next snippet, we show how to set up the request object and instruct
the model to update. We also instruct the map to center on the start
coordinate for our routing request.
- \snippet mapviewer/mapviewer.qml routerequest0
- \snippet mapviewer/mapviewer.qml routerequest1
+ \snippet mapviewer/map/MapComponent.qml routerequest0
+ \snippet mapviewer/map/MapComponent.qml routerequest1
+ \snippet mapviewer/map/MapComponent.qml routerequest2
This is all that is required to display a Route on the Map. However, it is
also useful to be able to retrieve the written directions and explanation
- of the travel route. In the example, these are displayed in the pull-out
- on the left-hand side of the map. To create this pull-out's contents, we
- use a standard \l {Models and Views in Qt Quick#ListModel}{ListModel} and
+ of the travel route. In the example, these are displayed in a \l {ListView} element.
+ To create this content, we use a standard \l {Models and Views in Qt Quick#ListModel}{ListModel} and
\l {ListView} pair. The data in the \l {Models and Views in Qt Quick#ListModel}{ListModel} is
built from the routeModel's output:
- \snippet mapviewer/content/map/MapComponent.qml routeinfomodel
+ \snippet mapviewer/forms/RouteList.qml routeinfomodel0
+ \snippet mapviewer/forms/RouteList.qml routeinfomodel1
+ \snippet mapviewer/forms/RouteList.qml routeinfomodel3
- Inside the RouteModel, we add an
+ Inside the RouteModel, as you can see above, we add an
\l{QtLocation::RouteModel::status}{onStatusChanged} handler, which
- calls the \c{update()} function we defined on the model:
+ calls the \c{showRouteList()} which updates the \c{routeInfoModel}:
- \snippet mapviewer/content/map/MapComponent.qml routemodel1
+ \snippet mapviewer/forms/RouteList.qml routeinfomodel2
*/