MapRectangle QML Type
MapRectangle 类型用于在地图上显示矩形。更多
Import Statement: | import QtLocation 6.9 |
Since: | QtLocation 5.5 |
- 所有成员(包括继承成员)列表
- MapRectangle 是QML 地图插件的一部分。
属性
- autoFadeIn : bool
- border
- border.color : color
- border.width : int
- bottomRight : coordinate
- color : color
- opacity : real
- referenceSurface : enum
(since 6.5)
- topLeft : coordinate
详细说明
MapRectangle 类型在地图上显示一个矩形。矩形是多边形的一种特例,它有 4 个顶点和 4 条 "直 "边。在这种情况下,"直 "意味着左上角的点与右上角的点(上边)具有相同的纬度,左下角的点与右下角的点(下边)具有相同的纬度。同样,左边的点具有相同的经度,右边的点具有相同的经度。
要指定矩形,需要一个topLeft 和bottomRight 点,这两个点都由coordinate 给出。
默认情况下,矩形以透明填充和 1 像素厚的黑色边框显示。可以使用color 、border.color 和border.width 属性进行更改。
注: 与MapPolygon 类型类似,MapRectangles 也是地理项,因此拖动 MapRectangle 会导致其顶点在地理坐标空间中重新计算。当拖动到不同的纬度时,项目会发生明显的拉伸,但其边缘仍保持平直。
使用示例
下面的代码段显示了一张包含一个 MapRectangle 的地图,其范围从(-27,153)到(-28,153.5),位于澳大利亚布里斯班附近。矩形填充为绿色,边框为 2 像素的黑色。
Map { MapRectangle { color: 'green' border.width: 2 topLeft { latitude: -27 longitude: 153 } bottomRight { latitude: -28 longitude: 153.5 } } }
属性文档
autoFadeIn : bool |
该属性用于设置从极低缩放级别开始放大地图时,项目是否会自动淡入。默认情况下为true
。将此属性设置为false
会使地图项目始终具有QtQuick::Item::opacity 属性指定的不透明度,默认为 1.0。
该属性是边框属性组的一部分。border 属性组包含用于绘制矩形边框的宽度和颜色。宽度以像素为单位,与地图缩放级别无关。
默认值对应宽度为 1 像素的黑色边框。如果没有线条,则使用 0 宽度或透明色。
bottomRight : coordinate |
该属性保存MapRectangle 的右下角坐标,可用于检索其经度、纬度和高度。
color : color |
该属性显示矩形的填充颜色。如果不填充,则使用透明色。
opacity : real |
该属性用于设置项目的不透明度。不透明度指定为介于 0(完全透明)和 1(完全不透明)之间的数字。默认值为 1。
不透明度为 0 的项目仍会接收鼠标事件。要停止鼠标事件,可将项目的可见属性设置为 false。
referenceSurface : enum |
该属性决定了矩形的参考表面。如果将其设置为QLocation::ReferenceSurface::Map ,则边缘点会与地图上的直线相连。如果设置为QLocation::ReferenceSurface::Globe ,则边缘点按照大圆路径连接,大圆路径描述了球面上两点的最短连接。默认值为QLocation::ReferenceSurface::Map 。
此属性在 Qt 6.5 中引入。
topLeft : coordinate |
该属性保存MapRectangle 的左上角坐标,可用于检索其经度、纬度和高度。
© 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.