The ExtendedAttributes type holds additional data about a Place . 更多...
import 语句: | import QtLocation 5.12 |
Since: | QtLocation 5.5 |
实例化: | QQmlPropertyMap |
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
项。
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 了解细节。
Some attributes may not be intended to be readable by end users, the label field of such attributes is empty to indicate this fact.
注意: ExtendedAttributes instances are only ever used in the context of Place s. 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"
另请参阅 PlaceAttribute and QQmlPropertyMap .
This signal is emitted when the set of attributes changes. key is the key corresponding to the value that was changed.
相应处理程序是
onValueChanged
.
variant keys () |
Returns an array of place attribute keys currently stored in the map.