Show:

An encapsulation of all field data that makes up a Feature.

Methods

count () Number

Returns the number of fields.

Returns:

Number

Example:

feature.fields.count();`
forEach
(
  • callback
)

Iterates through all fields using a callback function.

Parameters:

  • callback ForEachCb

    The callback to be called with each feature value and key.

Example:

layer.features.get(0).fields.forEach(function(value, key) { ... });`
get
(
  • key
)
Any

Returns a field's value.

Parameters:

  • key String | Number

    Feature name or index.

Returns:

Any

Example:

value = feature.fields.get(0);
value = feature.fields.get('field');`
getNames () String[]

Returns a list of field name.

Returns:

String[]:

List of field names.

indexOf
(
  • name
)
Number

Returns the index of a field, given its name.

Parameters:

  • name String

Returns:

Number:

Index or, -1 if it cannot be found.

Example:

var index = feature.fields.indexOf('field');`
map<U>
(
  • callback
)
U[]

Iterates through field definitions using a callback function and builds an array of the returned values.

Parameters:

  • callback mapCb

    The callback to be called with each Any

Returns:

U[]

Example:

var result = layer.features.get(0).fields.map(function(array, i) {
    return value;
});`
reset
(
  • values
)
Void

Resets all fields.

Parameters:

  • [values] Object optional

Returns:

Void

Example:

feature.fields.reset();`
set
(
  • key
  • value
)

Sets feature field(s).

Parameters:

  • key String | Number

    Field name or index

  • value Any

Example:

// most-efficient, least flexible. requires you to know the ordering of the
fields: feature.fields.set(['Something']); feature.fields.set(0,
'Something');

// most flexible.
feature.fields.set({name: 'Something'});
feature.fields.set('name', 'Something');
set
(
  • fields
)

Parameters:

  • fields Object
toArray () Any[]

Outputs the field values as a pure JS array.

Returns:

Any[]
toJSON () String

Outputs the fields as a serialized JSON string.

Returns:

String:

Serialized JSON

toObject () Any

Outputs the field data as a pure JS object.

Returns:

Any

Attributes

feature

gdal.Feature readonly

Parent feature