gdal.FeatureFields
An encapsulation of all field data that makes up a Feature.
Table of Contents
Methods
count
()
Integer
Returns the number of fields.
Returns:
Example:
feature.fields.count();`
forEach
-
callback
Iterates through all fields using a callback function.
Parameters:
-
callbackFunctionThe callback to be called with each feature
valueandkey.
Example:
layer.features.get(0).fields.forEach(function(value, key) { ... });`
get
-
key
Returns a field's value.
Parameters:
-
keyString | IntegerFeature name or index.
Returns:
Example:
value = feature.fields.get(0);
value = feature.fields.get('field');`
getNames
()
Array
Returns a list of field name.
Returns:
List of field names.
indexOf
-
name
Returns the index of a field, given its name.
Parameters:
-
nameString
Returns:
Index or, -1 if it cannot be found.
Example:
var index = feature.fields.indexOf('field');`
map
-
callback
Iterates through all fields using a callback function and builds an array of the returned values.
Parameters:
-
callbackFunctionThe callback to be called with each feature
valueandkey.
Example:
var result = layer.features.get(0).fields.map(function(value, key) {
return value;
});`
reset
-
values -
value
Resets all fields.
Parameters:
-
[values]Object optional -
valueMixed
Example:
feature.fields.reset();`
set
-
key -
value
Sets feature field(s).
Parameters:
-
keyString | IntegerField name or index
-
valueMixed
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:
toJSON
()
String
Outputs the fields as a serialized JSON string.
Returns:
Serialized JSON
toObject
()
Object
Outputs the field data as a pure JS object.