Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
maps.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2017 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
5
/*!
6
\page location-maps-qml.html
7
\title Maps and Navigation (QML)
8
9
\brief Provides QtQuick user interfaces for displaying, navigating and
10
interacting with maps, as well as geocoding and navigation.
11
12
\b{Maps and Navigation} provides QtQuick user interface types for
13
displaying geographic information on a map, as well as allowing user
14
interaction with map overlay objects and the display itself. It also
15
contains utilities for geocoding (finding a geographic coordinate from a
16
street address) and navigation (including driving and walking directions).
17
18
To perform navigation we need \l {route}s from start to destination. These
19
routes are made up of segments, where each \l {QtLocation::}{routeSegment} can
20
be considered a navigation subtask; for example, "drive 100 meters", or "turn
21
left". The beginning and end of each segment is a \e waypoint, that is, one part
22
of the journey.
23
24
A typical use case for the API is a user looking for a particular type of place,
25
such as a restaurant; the user enters a search string into the map application
26
and is presented with a list of results for restaurants "near" the device. The
27
application can then be used to navigate to the chosen destination using a route
28
that is optimized according to features in the environment that may help or
29
hinder the journey. The navigation then proceeds with the user's progress
30
monitored by means of the current location.
31
32
The types build upon the API concepts and types in the
33
\l{Positioning (QML)}{QML Positioning API}. A more hands-on introduction of the
34
Maps and Navigation types can be found in the
35
\l {QML Maps}{Maps and Navigation tutorial}.
36
37
\section1 Maps
38
39
\section2 Displaying Maps
40
41
Displaying a map is done using the \l{QtLocation::Map}{Map} QML types. The Map type supports
42
user interaction through the \l{QtLocation::MapView}{MapView} QML type. The Map
43
object draws the map on-screen using OpenGL (ES), allowing for hardware-accelerated rendering
44
where available.
45
46
\b{Key Types}
47
\table
48
\row
49
\li \l{QtLocation::Plugin}{Plugin}
50
\li A location-based services plugin provides data including map data which is then displayed in a Map object.
51
\row
52
\li \l{QtLocation::Map}{Map}
53
\li QtQuick item to display a map on-screen.
54
\row
55
\li \l{QtLocation::MapView}{MapView}
56
\li Interaction helper for panning, flicking and pinch-to-zoom gesture on a Map.
57
\endtable
58
59
Note that the client must create a \l{QtLocation::Plugin}{Plugin} object
60
prior to using a \l{QtLocation::Map}{Map} type in order to have access
61
to map data to display.
62
63
\section2 Putting Objects on a Map (Map Overlay Objects)
64
65
Maps can also contain map overlay objects, which are used to display information
66
on its surface. There is a set of basic pre-defined map overlay objects, as well
67
as the ability to implement custom map overlay objects using the
68
\l{QtLocation::MapQuickItem}{MapQuickItem} type, which can contain any
69
standard QtQuick item.
70
71
\b{Key Types}
72
\table
73
\row
74
\li \l{QtLocation::MapCircle}{MapCircle}
75
\li A geographic circle (all points at a set distance from a center), optionally with a border.
76
\row
77
\li \l{QtLocation::MapRectangle}{MapRectangle}
78
\li A rectangle whose top left and bottom right points are specified as
79
\l {coordinate} types, optionally with a border.
80
\row
81
\li \l{QtLocation::MapPolygon}{MapPolygon}
82
\li A polygon made of an arbitrary list of \l {coordinate}{coordinates}.
83
\row
84
\li \l{QtLocation::MapPolyline}{MapPolyline}
85
\li A polyline made of an arbitrary list of \l {coordinate}{coordinates}.
86
\row
87
\li \l{QtLocation::MapQuickItem}{MapQuickItem}
88
\li Turns any arbitrary QtQuick Item into a map overlay object. MapQuickItem is an enabler for specifying custom map overlay objects.
89
\endtable
90
91
\section2 Model-View Design with Map Overlay Objects
92
93
To automatically generate map overlay objects based on the contents of a QtQuick
94
model (for example a ListModel item), the \l{QtLocation::MapItemView}{MapItemView}
95
type is available. It accepts any map overlay object as its delegate, and can
96
only be created within a \l{QtLocation::Map}{Map}.
97
98
\b{Key Types}
99
\table
100
\row
101
\li \l{QtLocation::MapItemView}{MapItemView}
102
\li Populates a Map with map overlay objects based on the data provided by a model.
103
\endtable
104
105
\section2 Interaction with Map Overlay Objects
106
107
Properties of map overlay objects that influence their appearance on the display can
108
be changed at any time, and many can also be used in animations. Animating
109
coordinate-based map overlay objects, such as MapPolygon and MapPolyline, is not yet
110
available.
111
112
\section1 Geocoding -- Address to Coordinate and Vice Versa
113
114
Geocoding is the translation of geographic coordinates into addresses, or vice
115
versa. Such a translation usually involves sending the source data to a server
116
which then performs the translation and returns the results, although some
117
location-based service provider \l{QtLocation::Plugin}{plugins} may be able to
118
provide some geocoding functionality without sending data to a remote server.
119
The availability and accuracy of the translation usually depends on the location
120
or address being translated, as different areas of the Earth are mapped to
121
varying degrees of accuracy.
122
123
A geocoding query in QML is performed using the
124
\l{QtLocation::GeocodeModel}{GeocodeModel} type. For an address-to-coordinate
125
query, its \c{query} property may be set to either an
126
\l [QtPositioning]{Address} object or a string containing the textual
127
form of the address to search for. To perform the reverse, the same property
128
can be set to a \l {coordinate} instead. Results are made available in the
129
contents of the model.
130
131
\b{Key Types}
132
\table
133
\row
134
\li \l{QtLocation::Plugin}{Plugin}
135
\li A location-based services plugin provides data including geocoding translation results which are exposed to clients via a GeocodeModel.
136
\row
137
\li \l{QtLocation::GeocodeModel}{GeocodeModel}
138
\li Queries the Plugin for geocoding translations and provides access to results via indexes in the model.
139
\row
140
\li \l[QtPositioning]{Address}
141
\li Structured address for use in queries and results of geocoding.
142
\endtable
143
144
Note that the client must create a \l{QtLocation::Plugin}{Plugin} object
145
prior to using a \l{QtLocation::GeocodeModel}{GeocodeModel} object. This
146
will enable access to geocoding translation services and thus data to display.
147
148
\section1 Routing and Navigation
149
150
Routing is the determination of a navigable path from one point to another on
151
a map. Given a map that is aware of features that aid or hinder navigation, such as
152
bridges, waterways and so on, a series of segments that make
153
up the journey can be constructed. If these \l {routeSegment}s are simple then we can
154
add navigation information at the connecting points, \l {routeManeuver}s,
155
between the segments.
156
157
\b{Key Types}
158
\table
159
\row
160
\li \l route
161
\li The entire path to be navigated.
162
\row
163
\li \l{QtLocation::routeSegment}{routeSegment}
164
\li The individual components of a route.
165
\row
166
\li \l{QtLocation::routeManeuver}{routeManeuver}
167
\li The navigation information that joins segments.
168
\row
169
\li \l{QtLocation::RouteModel}{RouteModel}
170
\li The means of making requests on the backend to supply route
171
information.
172
\endtable
173
174
175
176
177
178
179
*/
180
181
182
/*!
183
\page location-maps-cpp.html
184
\title Maps and Navigation (C++)
185
186
\brief Provides C++ classes for Geocoding and Navigation.
187
188
\b{Maps and Navigation} provides C++ utilities for geocoding (finding a
189
geographic coordinate from a street address) and navigation (including driving
190
and walking directions).
191
192
Currently it is not possible to interact with maps via C++. Mapping applications
193
must use the \l {Maps and Navigation (QML)} API.
194
195
196
\section1 Geocoding
197
198
In C++, an address-to-coordinate query is performed using the
199
\l{QGeoCodingManager::geocode()}{geocode()} method of the QGeoCodingManager
200
class. For coordinate-to-address queries, the
201
\l{QGeoCodingManager::reverseGeocode()}{reverseGeocode()} method is available
202
on the same class. Instances of QGeoCodingManager are available via
203
\l{QGeoServiceProvider}.
204
205
\b{Key Classes}
206
\table
207
\row
208
\li \l{QGeoServiceProvider}
209
\li Provides a QGeoCodingManager instance ready for use.
210
\row
211
\li \l{QGeoCodingManager}
212
\li Accepts queries and produces QGeoCodeReply objects.
213
\row
214
\li \l{QGeoCodeReply}
215
\li Contains the results of a geocoding query.
216
\endtable
217
218
\section1 Navigation
219
220
In C++, a route query is performed using the \l{QGeoRoutingManager::calculateRoute()}{calculate()}
221
method of the QGeoRoutingManager class. The returned route reply can contain
222
multiple routes to the same destination.
223
224
\b{Key Classes}
225
\table
226
\row
227
\li \l{QGeoServiceProvider}
228
\li Provides a QGeoCodingManager instance ready for use.
229
\row
230
\li \l{QGeoRoutingManager}
231
\li Accepts queries and produces QGeoRouteReply objects.
232
\row
233
\li \l{QGeoRouteReply}
234
\li Contains the results of a routing query.
235
\row
236
\li \l{QGeoRoute}
237
\li Contains information about a route.
238
\endtable
239
240
241
*/
qtlocation
src
location
doc
src
maps.qdoc
Generated on
for Qt by
1.14.0