QtLocation.MapQuickItem

The MapQuickItem type displays an arbitrary Qt Quick object on a Map. More...

Import Statement: import QtLocation 5.3
Since: Qt Location 5.0

Properties

Detailed Description

The MapQuickItem will follow the panning (and optionally, the zooming) of the Map as if it is on the Map surface.

The sourceItem property contains the Qt Quick item to be drawn, which can be any kind of visible type.

Positioning and Sizing

The positioning of the coordinate is set, it specifies a longitude/latitude coordinate for the item to be placed at. The set coordinate will line up with the top-left corner of the contained item when shown on the screen.

The coordinate when displayed.

In addition to being anchored to the map, the zoomLevel is not set is for the item to be drawn "on the screen" rather than "on the map", so that its size remains the same regardless of the zoom level of the Map.

Performance

Performance of a MapQuickItem is normally in the same ballpark as the contained Qt Quick item alone. Overheads added amount to a translation and (possibly) scaling of the original item, as well as a transformation from longitude and latitude to screen position.

Limitations

Note: Due to an implementation detail, items placed inside a MapQuickItem by its id, and avoid the use of anchor in the sourceItem.

Example Usage

The following snippet shows a MapQuickItem containing an Image object, to display a Marker on the Map. This strategy is used to show the map markers in the MapViewer example.

MapQuickItem {
id: marker
anchorPoint.x: image.width/4
anchorPoint.y: image.height
sourceItem: Image {
id: image
}
}

src="https://assets.ubuntu.com/v1/fe21dbdf-api-mapquickitem.png" alt="" />

Property Documentation

anchorPoint : QPointF

This property determines which point on the sourceItem that will be lined up with the coordinate on the map.


coordinate : anchorPoint is kept aligned with this coordinate when drawn on the map.

In the image below, there are 3 MapQuickItems that are identical except for the value of their anchorPoint for each are written on top of the item.

src="https://assets.ubuntu.com/v1/d364fc36-api-mapquickitem-anchor.png" alt="" />


sourceItem : object

This property holds the source item that will be drawn on the map.


zoomLevel : real

This property controls the scaling behaviour of the contents of the MapQuickItem. In particular, by setting this property it is possible to choose between objects that are drawn on the screen (and sized in screen pixels), and those drawn on the map surface (which change size with the zoom level of the map).

The default value for this property is 0.0, which corresponds to drawing the object on the screen surface. If set to another value, the object will be drawn on the map surface instead. The value (if not zero) specifies the zoomLevel at which the object will be visible at a scale of 1:1 (ie, where object pixels and screen pixels are the same). At zoom levels lower than this, the object will appear smaller, and at higher zoom levels, appear larger. This is in contrast to when this property is set to zero, where the object remains the same size on the screen at all zoom levels.


© Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.