MapRoute QML Type

MapRoute 类型可在地图上显示路线。更多

Import Statement: import QtLocation 6.9
Since: QtLocation 5.0

属性

详细说明

MapRoute 类型可在地图上显示通过RouteModel 或其他方式获取的路线,显示为沿路线路径的折线。

MapRoute 其实就是一个MapPolyline ,但路径是使用route 属性指定的,而不是直接在coordinates 中指定的。

默认情况下,路径显示为一条 1 像素粗的黑线。可以使用line.widthline.color 属性对此进行更改。

使用示例

下面是如何在map 上绘制route

import QtQuick
import QtPositioning
import QtLocation

Map {
    RouteModel {
        id: routeModel
    }

    MapItemView {
        model: routeModel
        delegate: routeDelegate
    }

    Component {
        id: routeDelegate

        MapRoute {
            route: routeData
            line.color: "blue"
            line.width: 5
            smooth: true
            opacity: 0.8
        }
    }
}

属性文档

line group

line.color : color

line.width : int

该属性是线条属性组的一部分。线条属性组包含用于绘制线条的宽度和颜色。

宽度以像素为单位,与地图缩放级别无关。默认值对应宽度为 1 像素的黑色边框。

如果没有线条,则使用 0 宽度或透明色。


route : Route

该属性包含要绘制的路线,可用来表示一条地理路线。


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.