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 [QtPositioning]{geoCoordinate} types, optionally with a border.
80
\row
81
\li \l{QtLocation::MapPolygon}{MapPolygon}
82
\li A polygon made of an arbitrary list of
83
\l [QtPositioning]{geoCoordinate}{coordinates}.
84
\row
85
\li \l{QtLocation::MapPolyline}{MapPolyline}
86
\li A polyline made of an arbitrary list of
87
\l [QtPositioning]{geoCoordinate}{coordinates}.
88
\row
89
\li \l{QtLocation::MapQuickItem}{MapQuickItem}
90
\li Turns any arbitrary QtQuick Item into a map overlay object. MapQuickItem is an enabler for specifying custom map overlay objects.
91
\endtable
92
93
\section2 Model-View Design with Map Overlay Objects
94
95
To automatically generate map overlay objects based on the contents of a QtQuick
96
model (for example a ListModel item), the \l{QtLocation::MapItemView}{MapItemView}
97
type is available. It accepts any map overlay object as its delegate, and can
98
only be created within a \l{QtLocation::Map}{Map}.
99
100
\b{Key Types}
101
\table
102
\row
103
\li \l{QtLocation::MapItemView}{MapItemView}
104
\li Populates a Map with map overlay objects based on the data provided by a model.
105
\endtable
106
107
\section2 Interaction with Map Overlay Objects
108
109
Properties of map overlay objects that influence their appearance on the display can
110
be changed at any time, and many can also be used in animations. Animating
111
coordinate-based map overlay objects, such as MapPolygon and MapPolyline, is not yet
112
available.
113
114
\section1 Geocoding -- Address to Coordinate and Vice Versa
115
116
Geocoding is the translation of geographic coordinates into addresses, or vice
117
versa. Such a translation usually involves sending the source data to a server
118
which then performs the translation and returns the results, although some
119
location-based service provider \l{QtLocation::Plugin}{plugins} may be able to
120
provide some geocoding functionality without sending data to a remote server.
121
The availability and accuracy of the translation usually depends on the location
122
or address being translated, as different areas of the Earth are mapped to
123
varying degrees of accuracy.
124
125
A geocoding query in QML is performed using the
126
\l{QtLocation::GeocodeModel}{GeocodeModel} type. For an address-to-coordinate
127
query, its \c{query} property may be set to either an
128
\l [QtPositioning]{Address} object or a string containing the textual
129
form of the address to search for. To perform the reverse, the same property
130
can be set to a \l [QtPositioning]{geoCoordinate} instead. Results are made
131
available in the contents of the model.
132
133
\b{Key Types}
134
\table
135
\row
136
\li \l{QtLocation::Plugin}{Plugin}
137
\li A location-based services plugin provides data including geocoding translation results which are exposed to clients via a GeocodeModel.
138
\row
139
\li \l{QtLocation::GeocodeModel}{GeocodeModel}
140
\li Queries the Plugin for geocoding translations and provides access to results via indexes in the model.
141
\row
142
\li \l[QtPositioning]{Address}
143
\li Structured address for use in queries and results of geocoding.
144
\endtable
145
146
Note that the client must create a \l{QtLocation::Plugin}{Plugin} object
147
prior to using a \l{QtLocation::GeocodeModel}{GeocodeModel} object. This
148
will enable access to geocoding translation services and thus data to display.
149
150
\section1 Routing and Navigation
151
152
Routing is the determination of a navigable path from one point to another on
153
a map. Given a map that is aware of features that aid or hinder navigation, such as
154
bridges, waterways and so on, a series of segments that make
155
up the journey can be constructed. If these \l {routeSegment}s are simple then we can
156
add navigation information at the connecting points, \l {routeManeuver}s,
157
between the segments.
158
159
\b{Key Types}
160
\table
161
\row
162
\li \l route
163
\li The entire path to be navigated.
164
\row
165
\li \l{QtLocation::routeSegment}{routeSegment}
166
\li The individual components of a route.
167
\row
168
\li \l{QtLocation::routeManeuver}{routeManeuver}
169
\li The navigation information that joins segments.
170
\row
171
\li \l{QtLocation::RouteModel}{RouteModel}
172
\li The means of making requests on the backend to supply route
173
information.
174
\endtable
175
176
177
178
179
180
181
*/
182
183
184
/*!
185
\page location-maps-cpp.html
186
\title Maps and Navigation (C++)
187
188
\brief Provides C++ classes for Geocoding and Navigation.
189
190
\b{Maps and Navigation} provides C++ utilities for geocoding (finding a
191
geographic coordinate from a street address) and navigation (including driving
192
and walking directions).
193
194
Currently it is not possible to interact with maps via C++. Mapping applications
195
must use the \l {Maps and Navigation (QML)} API.
196
197
198
\section1 Geocoding
199
200
In C++, an address-to-coordinate query is performed using the
201
\l{QGeoCodingManager::geocode()}{geocode()} method of the QGeoCodingManager
202
class. For coordinate-to-address queries, the
203
\l{QGeoCodingManager::reverseGeocode()}{reverseGeocode()} method is available
204
on the same class. Instances of QGeoCodingManager are available via
205
\l{QGeoServiceProvider}.
206
207
\b{Key Classes}
208
\table
209
\row
210
\li \l{QGeoServiceProvider}
211
\li Provides a QGeoCodingManager instance ready for use.
212
\row
213
\li \l{QGeoCodingManager}
214
\li Accepts queries and produces QGeoCodeReply objects.
215
\row
216
\li \l{QGeoCodeReply}
217
\li Contains the results of a geocoding query.
218
\endtable
219
220
\section1 Navigation
221
222
In C++, a route query is performed using the \l{QGeoRoutingManager::calculateRoute()}{calculate()}
223
method of the QGeoRoutingManager class. The returned route reply can contain
224
multiple routes to the same destination.
225
226
\b{Key Classes}
227
\table
228
\row
229
\li \l{QGeoServiceProvider}
230
\li Provides a QGeoCodingManager instance ready for use.
231
\row
232
\li \l{QGeoRoutingManager}
233
\li Accepts queries and produces QGeoRouteReply objects.
234
\row
235
\li \l{QGeoRouteReply}
236
\li Contains the results of a routing query.
237
\row
238
\li \l{QGeoRoute}
239
\li Contains information about a route.
240
\endtable
241
242
243
*/
qtlocation
src
location
doc
src
maps.qdoc
Generated on
for Qt by
1.16.1