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