Show:

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

Methods

count () Integer

Returns the number of fields.

Returns:

Integer

Example:

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

Defined in lib/gdal.js:192

Iterates through all fields using a callback function.

Parameters:

  • callback Function

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

Example:

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

Returns a field's value.

Parameters:

  • key String | Integer

    Feature name or index.

Returns:

Mixed | Undefined

Example:

value = feature.fields.get(0);
value = feature.fields.get('field');`
getNames () Array

Returns a list of field name.

Returns:

Array:

List of field names.

indexOf
(
  • name
)
Integer

Returns the index of a field, given its name.

Parameters:

  • name String

Returns:

Integer:

Index or, -1 if it cannot be found.

Example:

var index = feature.fields.indexOf('field');`
map
(
  • callback
)

Defined in lib/gdal.js:210

Iterates through all fields using a callback function and builds an array of the returned values.

Parameters:

  • callback Function

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

Example:

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

Resets all fields.

Parameters:

  • [values] Object optional
  • value Mixed

Example:

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

Sets feature field(s).

Parameters:

  • key String | Integer

    Field name or index

  • value Mixed

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');
toArray () Array

Outputs the field values as a pure JS array.

Returns:

Array
toJSON () String

Defined in lib/gdal.js:226

Outputs the fields as a serialized JSON string.

Returns:

String:

Serialized JSON

toObject () Object

Outputs the field data as a pure JS object.

Returns:

Object

Attributes

feature

gdal.Feature readonly

Parent feature