ExtendedAttributes QML Type

The ExtendedAttributes type holds additional data about a Place. More...

Import Statement: import QtLocation 5.14
Since: QtLocation 5.5
Instantiates: QQmlPropertyMap

Signals

Methods

Detailed Description

The ExtendedAttributes type is a map of PlaceAttributes. To access attributes in the map use the keys() method to get the list of keys stored in the map and use the [] operator to access the PlaceAttribute items.

The following are standard keys that are defined by the API. Plugin implementations are free to define additional keys. Custom keys should be qualified by a unique prefix to avoid clashes.

key description
openingHours The trading hours of the place
payment The types of payment the place accepts, for example visa, mastercard.
x_provider The name of the provider that a place is sourced from
x_id_<provider> (for example x_id_here) An alternative identifier which identifies the place from the perspective of the specified provider.

Some plugins may not support attributes at all, others may only support a certain set, others still may support a dynamically changing set of attributes over time or even allow attributes to be arbitrarily defined by the client application. The attributes could also vary on a place by place basis, for example one place may have opening hours while another does not. Consult the plugin references for details.

Some attributes may not be intended to be readable by end users, the label field of such attributes is empty to indicate this fact.

Note: ExtendedAttributes instances are only ever used in the context of Places. It is not possible to create an ExtendedAttributes instance directly or re-assign a Place's ExtendedAttributes property. Modification of ExtendedAttributes can only be accomplished via Javascript.

The following example shows how to access all PlaceAttributes and print them to the console:

import QtPositioning 5.5
import QtLocation 5.6

function printExtendedAttributes(extendedAttributes) {
    var keys = extendedAttributes.keys();
    for (var i = 0; i < keys.length; ++i) {
        var key = keys[i];
        if (extendedAttributes[key].label !== "")
            console.log(extendedAttributes[key].label + ": " + extendedAttributes[key].text);
    }
}

The following example shows how to assign and modify an attribute:

    //assign a new attribute to a place
    var smokingAttrib = Qt.createQmlObject('import QtLocation 5.3; PlaceAttribute {}', place);
    smokingAttrib.label = "Smoking Allowed"
    smokingAttrib.text = "No"
    place.extendedAttributes.smoking = smokingAttrib;

    //modify an existing attribute
    place.extendedAttributes.smoking.text = "Yes"

See also PlaceAttribute and QQmlPropertyMap.

Signal Documentation

void valueChanged(key, variant value)

This signal is emitted when the set of attributes changes. key is the key corresponding to the value that was changed.

The corresponding handler is onValueChanged.

Method Documentation

variant keys()

Returns an array of place attribute keys currently stored in the map.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.14/qml-qtlocation-extendedattributes.html