C
MapQuickItem QML Type
The MapQuickItem type displays an arbitrary Qt Quick object on a Map. More...
Import Statement: | import QtLocation |
Since: | Qt Quick Ultralite 2.11 |
Properties
- anchorPoint : point
- coordinate : geoCoordinate
- sourceItem : Item
Detailed Description
The MapQuickItem type is used to place an arbitrary Qt Quick object on a Map at a specified location and size. Compared to floating an item above the Map, a MapQuickItem follows the panning 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 MapQuickItem on the Map is controlled by two properties: coordinate and anchorPoint. If only coordinate is set, it specifies a longitude/latitude coordinate for the item to be placed at. The set coordinate lines up with the top-left corner of the contained item when shown on the screen.
The anchorPoint property provides a way to line up the coordinate with other parts of the item than just the top-left corner, by setting a number of pixels the item is offset by. A simple way to think about it is to note that the point given by anchorPoint on the item itself is the point that lines up with the given coordinate when displayed.
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 Map example.
import QtQuick import QtPositioning import QtLocation MapQuickItem { id: poiQt sourceItem: Image { id: markerImage source: "location-marker.png" Text { id: markerText text: "The Qt Company" font.pointSize: 7 font.bold: true anchors.bottom: parent.top anchors.horizontalCenter: parent.horizontalCenter } } center { latitude: 65.05877 longitude: 25.45545 } anchorPoint: Qt.point(sourceItem.width / 2, sourceItem.height / 2) }
Property Documentation
anchorPoint : point
This property determines which point on the sourceItem lines up with the coordinate on the map.
coordinate : geoCoordinate
This property holds the anchor coordinate of the MapQuickItem. The point on the sourceItem that is specified by 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 properties. The values of anchorPoint for each are written on top of the item.
sourceItem : Item
This property holds the source item that is drawn on the map.
Available under certain Qt licenses.
Find out more.