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
qdeclarativeroutemapitem.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
5
#
include
"qdeclarativeroutemapitem_p.h"
6
#
include
"qdeclarativepolylinemapitem_p.h"
7
8
#
include
<
QtQml
/
QQmlInfo
>
9
#
include
<
QtGui
/
QPainter
>
10
11
QT_BEGIN_NAMESPACE
12
13
/*!
14
\qmltype MapRoute
15
\nativetype QDeclarativeRouteMapItem
16
\inqmlmodule QtLocation
17
\ingroup qml-QtLocation5-maps
18
\since QtLocation 5.0
19
20
\brief The MapRoute type displays a Route on a Map.
21
22
The MapRoute type displays a Route obtained through a RouteModel or
23
other means, on the Map as a Polyline following the path of the Route.
24
25
MapRoute is really a \l MapPolyline, but with the path specified using the
26
\l route property instead of directly in
27
\l [QtPositioning]{geoCoordinate}{coordinates}.
28
29
By default, the route is displayed as a 1-pixel thick black line. This can
30
be changed using the \l line.width and \l line.color properties.
31
32
\section2 Example Usage
33
34
Here is how to draw a \l{route}{route} on a \l{Map}{map}:
35
36
\snippet declarative/maps.qml QtQuick import
37
\snippet declarative/maps.qml QtLocation import
38
\codeline
39
\snippet declarative/maps.qml MapRoute
40
*/
41
42
/*!
43
\qmlpropertygroup Location::MapRoute::line
44
\qmlproperty int MapRoute::line.width
45
\qmlproperty color MapRoute::line.color
46
47
This property is part of the line property group. The line
48
property group holds the width and color used to draw the line.
49
50
The width is in pixels and is independent of the zoom level of the map.
51
The default values correspond to a black border with a width of 1 pixel.
52
53
For no line, use a width of 0 or a transparent color.
54
*/
55
56
57
QDeclarativeRouteMapItem::QDeclarativeRouteMapItem(QQuickItem *parent)
58
: QDeclarativePolylineMapItem(parent)
59
{
60
setFlag(ItemHasContents,
true
);
61
}
62
63
QDeclarativeRouteMapItem::~QDeclarativeRouteMapItem()
64
{
65
}
66
67
/*!
68
\qmlproperty Route MapRoute::route
69
70
This property holds the route to be drawn which can be used
71
to represent one geographical route.
72
*/
73
QGeoRoute QDeclarativeRouteMapItem::route()
const
74
{
75
return
route_;
76
}
77
78
void
QDeclarativeRouteMapItem::setRoute(
const
QGeoRoute &route)
79
{
80
if
(route_ == route)
81
return
;
82
83
route_ = route;
84
85
setPathFromGeoList(route_.path());
86
87
emit routeChanged(route_);
88
}
89
90
void
QDeclarativeRouteMapItem::updateRoutePath()
91
{
92
setPathFromGeoList(route_.path());
93
}
94
95
/*!
96
\internal void QDeclarativeRouteMapItem::setPath(const QList<QGeoCoordinate> &value)
97
98
Used to disable path property on the RouteMapItem
99
*/
100
void
QDeclarativeRouteMapItem::setPath(
const
QList<QGeoCoordinate> &value)
101
{
102
Q_UNUSED(value);
103
qWarning() <<
"Can not set the path on QDeclarativeRouteMapItem."
104
<<
"Please use the route property instead."
;
105
}
106
107
QT_END_NAMESPACE
qtlocation
src
location
quickmapitems
qdeclarativeroutemapitem.cpp
Generated on
for Qt by
1.16.1