MapPolyline QML Type

MapPolyline type displays a polyline on a map. 更多...

导入语句: import QtLocation 5.3
Since: Qt Location 5.0

特性

方法

详细描述

MapPolyline type displays a polyline on a map, specified in terms of an ordered list of coordinates coordinates on the path cannot be directly changed after being added to the Polyline. Instead, copy the path into a var, modify the copy and reassign the copy back to the path .

var path = mapPolyline.path;
path[0].latitude = 5;
mapPolyline.path = path;
					

Coordinates can also be added and removed at any time using the addCoordinate and removeCoordinate 方法。

By default, the polyline is displayed as a 1-pixel thick black line. This can be changed using the line.width and line.color 特性。

性能

MapPolylines have a rendering cost that is O(n) with respect to the number of vertices. This means that the per frame cost of having a polyline on the Map grows in direct proportion to the number of points in the polyline.

Like the other map objects, MapPolyline is normally drawn without a smooth appearance. Setting the opacity property will force the object to be blended, which decreases performance considerably depending on the hardware in use.

注意: MapPolylines are implemented using the OpenGL GL_LINES primitive. There have been occasional reports of issues and rendering inconsistencies on some (particularly quite old) platforms. No workaround is yet available for these issues.

用法范例

The following snippet shows a MapPolyline with 4 points, making a shape like the top part of a "question mark" (?), near Brisbane, Australia. The line drawn is 3 pixels in width and green in color.

Map {
    MapPolyline {
        line.width: 3
        line.color: 'green'
        path: [
            { latitude: -27, longitude: 153.0 },
            { latitude: -27, longitude: 154.1 },
            { latitude: -28, longitude: 153.5 },
            { latitude: -29, longitude: 153.5 }
        ]
    }
}
					

特性文档编制

line group

line.width : int

line.color : color

This property is part of the line property group. The line property group holds the width and color used to draw the line.

The width is in pixels and is independent of the zoom level of the map. The default values correspond to a black border with a width of 1 pixel.

For no line, use a width of 0 or a transparent color.


path : list < coordinate >

This property holds the ordered list of coordinates which define the polyline.


方法文档编制

void addCoordinate ( coordinate )

Adds a coordinate to the end of the path.

另请参阅 insertCoordinate , removeCoordinate ,和 path .


coordinate containsCoordinate ( coordinate )

Returns true if the given coordinate is part of the path.

This QML method was introduced in Qt Location 5.6.


coordinate coordinateAt ( index )

Gets the coordinate of the polyline at the given index . If the index is outside the path's bounds then an invalid coordinate is returned.

This QML method was introduced in Qt Location 5.6.


void insertCoordinate ( index , coordinate )

插入 coordinate to the path at the given index .

This QML method was introduced in Qt Location 5.6.

另请参阅 addCoordinate , removeCoordinate ,和 path .


int pathLength ()

Returns the number of coordinates of the polyline.

This QML method was introduced in Qt Location 5.6.

另请参阅 path .


void removeCoordinate ( index )

Removes a coordinate from the path at the given index .

index is invalid then this method does nothing.

This QML method was introduced in Qt Location 5.6.

另请参阅 addCoordinate , insertCoordinate ,和 path .


void removeCoordinate ( coordinate )

移除 coordinate from the path. If there are multiple instances of the same coordinate, the one added last is removed.

coordinate is not in the path this method does nothing.

另请参阅 addCoordinate , insertCoordinate ,和 path .


void replaceCoordinate ( index , coordinate )

Replaces the coordinate in the current path at the given index with the new coordinate .

This QML method was introduced in Qt Location 5.6.

另请参阅 addCoordinate , insertCoordinate , removeCoordinate ,和 path .