Qt Reference Documentation

Location

The Location element holds location data. More...

Inherits QtObject

This element was introduced in QtLocation 5.0.

Properties

Detailed Description

Location elements represent a geographic "location", in a human sense. This consists of a specific Coordinate, as well as an Address and a BoundingBox. The BoundingBox delineates the limits of what geographic area is considered "part of" the location. For example, a Location representing a house would have the Coordinate set to the center of the house's block of land, the Address to its street address, and the BoundingBox would show roughly the limits of the block itself.

The Location element is most commonly seen as the contents of a search model such as the GeocodeModel. When a GeocodeModel returns the list of locations found for a given query, it represents these as Location elements.

Example Usage

The following example shows a simple Location element being declared with a set coordinate and address.

 Address {
     id: houseAddress
     ...
 }

 Coordinate {
     id: coord
     latitude: -27.3; longitude: 153.1
 }

 Location {
     coordinate: coord
     address: houseAddress
 }

Property Documentation

address : Address

This property holds address of the location.


boundingBox : BoundingBox

This property holds bounding box of area on map occupied by location.

Note: this property's changed() signal is currently emitted only if the whole element changes, not if only the contents of the element change.


coordinate : Coordinate

This property holds display coordinates of the location.

Note: this property's changed() signal is currently emitted only if the whole element changes, not if only the contents of the element change.


label : string

This property holds the location label value.


latitude : double

This property holds the location latitude value.


location : QGeoLocation

This property is used to provide an interface between C++ and QML code. First a pointer to a Location object must be obtained from C++, then use the property() and setProperty() functions to get and set the location property.

The following gets the QGeoLocation representing this object from C++:

 QGeoLocation geoLocation = qmlObject->property("location").value<QGeoLocation>();

The following sets the properties of this object based on a QGeoLocation object from C++:

 qmlObject->setProperty("location", QVariant::fromValue(geoLocation));

longitude : double

This property holds the location longitude value .