MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QML MapPolyline Element

The MapPolyline element displays a polyline on a map. More...

This element was introduced in Mobility 1.2.

Properties

Methods

Detailed Description

The polyline is specified in terms of an ordered list of coordinates. Any invalid coordinates in the list will be ignored.

If the list contains less than 2 valid coordinates the polyline will not be displayed.

Simplistic example to illustrate, this element could be defined in Map body:

 MapPolyline {
     id: polyline
     border {color: "red"; width: 4}
     Coordinate {
         id: polylineTopLeftCoordinate
         latitude: -28.35
         longitude: 153.4
     }
     Coordinate {
         id: polylineRightCoordinate
         latitude: -28.34
         longitude: 153.45
     }
     Coordinate {
         id: polylineBottomLeftCoordinate
         latitude: -28.33
         longitude: 153.4
     }
     onPathChanged: {
         console.log('Polyline pathChanged signal received')
     }
 }

The MapPolyline element is part of the QtMobility.location 1.2 module.

Property Documentation

border.width : int

border.color : color

These properties hold the width and color used to draw the border of the circle.

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.

This property group was introduced in Mobility 1.2.


defaultpath : list<Coordinate>

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

This property group was introduced in Mobility 1.2.


visible : bool

This property holds a boolean corresponding to whether or not the polyline is visible.

This property group was introduced in Mobility 1.2.


z : int

This property holds the z-value of the polyline.

Map objects are drawn in z-value order, and objects with the same z-value will be drawn in insertion order.

This property group was introduced in Mobility 1.2.


Method Documentation

MapPolyline::addCoordinate ( Coordinate )

Adds coordinate to the path. The resulting path is derived from values at the time of assignment, meaning that later changes in values are not reflected in the path.

A basic example is to draw the path where one has been:

 PositionSource {
     id: myPositionSource
     active: true
     nmeaSource: "nmealog.txt"
     updateInterval: 2000
     onPositionChanged: {
         console.log("Position changed in PositionSource")
         myPathPolyline.addCoordinate(position.coordinate)
     }
 }

This documentation was introduced in Mobility 1.2.

See also removeCoordinate.


MapPolyline::removeCoordinate ( Coordinate )

Remove coordinate from the path. If there are multiple instances of the same coordinate, the one added last is removed. Removed Coordinate is not deleted.

 onButton2Clicked: {
     polyline.removeCoordinate(map.center)
 }

If more finetuned control is needed, one can also iterate and/or use the inherent index property of the path list.

 onButton1Clicked: {
     for (var index = 0; index < polyline.path.length; index++)  {
         console.log("Index, latitude:" + index + " , " + polyline.path[index].latitude);
     }
     polyline.removeCoordinate(polyline.path[2])
 }

This documentation was introduced in Mobility 1.2.

See also addCoordinate.