MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QML MapPolygon Element

The MapPolygon element displays a polygon on a map. More...

This element was introduced in Mobility 1.2.

Properties

Methods

Detailed Description

The polygon 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 3 valid coordinates the polygon will not be displayed.

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

 MapPolygon {
     id: polygon
     color: "blue"
     Coordinate {
         id: topLeftCoordinate
         latitude: -28.35
         longitude: 153.4
     }
     Coordinate {
         id: rightCoordinate
         latitude: -28.34
         longitude: 153.45
     }
     Coordinate {
         id: bottomLeftCoordinate
         latitude: -28.33
         longitude: 153.4
     }
 }

The MapPolygon 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.


color : color

This property holds the color used to fill the circle.

The default value corresponds to 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 polygon.

This property group was introduced in Mobility 1.2.


visible : bool

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

This property group was introduced in Mobility 1.2.


z : int

This property holds the z-value of the polygon.

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

MapPolygon::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.

 onButton1Clicked: {
     polygon.addCoordinate(map.center)
 }

This documentation was introduced in Mobility 1.2.

See also removeCoordinate.


MapPolygon::removeCoordinate ( Coordinate )

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

 onButton2Clicked: {
     polygon.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.