attributes property
A dictionary of attributes for this feature.
You can configure an MLNVectorStyleLayer object to include or exclude a
specific feature in an MLNShapeSource or MLNVectorTileSource. In the
MLNVectorStyleLayer/predicate property, compare a key of the attribute
dictionary to the value you want to include. For example, if you want an
MLNLineStyleLayer object to display only important features, you might assign
a value above 50 to the important features’ importance attribute, then set
MLNVectorStyleLayer/predicate to an
NSPredicate with the format
importance > 50.
You can also configure many layout and paint attributes of an MLNStyleLayer
object to match the value of an attribute in this dictionary whenever it
renders this feature. For example, if you display features in an
MLNShapeSource using an MLNCircleStyleLayer, you can assign a halfway
attribute to each of the source’s features, then set
MLNCircleStyleLayer/circleRadius to an expression for the key path halfway.
The MLNSymbolStyleLayer/text and MLNSymbolStyleLayer/iconImageName
properties allow you to use attributes yet another way. For example, to label
features in an MLNShapeSource object by their names, you can assign a name
attribute to each of the source’s features, then set
MLNSymbolStyleLayer/text to an expression for the constant string value
{name}. See the
Predicates and Expressions
guide for more information about expressions.
In vector tiles loaded by MLNVectorTileSource objects, the keys and values of
each feature’s attribute dictionary are determined by the source. Each
attribute name is a string, while each attribute value may be a null value,
Boolean value, integer, floating-point number, or string. These data types are
mapped to instances of the following Foundation classes:
| In the tile source | In this dictionary |
|---|---|
| Null | NSNull |
boolValue property) |
|
NSNumber (use the unsignedLongLongValue or longLongValue property) |
|
| number | NSNumber (use the doubleValue property) |
| String | NSString |
When adding a feature to an MLNShapeSource, use the same Foundation types
listed above for each attribute value. In addition to the Foundation types, you
may also set an attribute to an NSColor (macOS) or UIColor (iOS), which
will be converted into its
CSS string representation
when the feature is added to an MLNShapeSource. This can be convenient when
using the attribute to supply a value for a color-typed layout or paint
attribute via a key path expression.
Note that while it is possible to change this value on feature
instances obtained from MLNMapView/visibleFeaturesAtPoint: and related
methods, there will be no effect on the map. Setting this value can be useful
when the feature instance is used to initialize an MLNShapeSource and that
source is added to the map and styled.
Implementation
objc.NSDictionary get attributes {
final _ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_attributes);
return objc.NSDictionary.castFromPointer(_ret, retain: true, release: true);
}
A dictionary of attributes for this feature.
You can configure an MLNVectorStyleLayer object to include or exclude a
specific feature in an MLNShapeSource or MLNVectorTileSource. In the
MLNVectorStyleLayer/predicate property, compare a key of the attribute
dictionary to the value you want to include. For example, if you want an
MLNLineStyleLayer object to display only important features, you might assign
a value above 50 to the important features’ importance attribute, then set
MLNVectorStyleLayer/predicate to an
NSPredicate with the format
importance > 50.
You can also configure many layout and paint attributes of an MLNStyleLayer
object to match the value of an attribute in this dictionary whenever it
renders this feature. For example, if you display features in an
MLNShapeSource using an MLNCircleStyleLayer, you can assign a halfway
attribute to each of the source’s features, then set
MLNCircleStyleLayer/circleRadius to an expression for the key path halfway.
The MLNSymbolStyleLayer/text and MLNSymbolStyleLayer/iconImageName
properties allow you to use attributes yet another way. For example, to label
features in an MLNShapeSource object by their names, you can assign a name
attribute to each of the source’s features, then set
MLNSymbolStyleLayer/text to an expression for the constant string value
{name}. See the
Predicates and Expressions
guide for more information about expressions.
In vector tiles loaded by MLNVectorTileSource objects, the keys and values of
each feature’s attribute dictionary are determined by the source. Each
attribute name is a string, while each attribute value may be a null value,
Boolean value, integer, floating-point number, or string. These data types are
mapped to instances of the following Foundation classes:
| In the tile source | In this dictionary |
|---|---|
| Null | NSNull |
boolValue property) |
|
NSNumber (use the unsignedLongLongValue or longLongValue property) |
|
| number | NSNumber (use the doubleValue property) |
| String | NSString |
When adding a feature to an MLNShapeSource, use the same Foundation types
listed above for each attribute value. In addition to the Foundation types, you
may also set an attribute to an NSColor (macOS) or UIColor (iOS), which
will be converted into its
CSS string representation
when the feature is added to an MLNShapeSource. This can be convenient when
using the attribute to supply a value for a color-typed layout or paint
attribute via a key path expression.
Note that while it is possible to change this value on feature
instances obtained from MLNMapView/visibleFeaturesAtPoint: and related
methods, there will be no effect on the map. Setting this value can be useful
when the feature instance is used to initialize an MLNShapeSource and that
source is added to the map and styled.
Implementation
set attributes(objc.NSDictionary value) {
_objc_msgSend_xtuoz7(this.ref.pointer, _sel_setAttributes_, value.ref.pointer);
}