add an optional argument to getAttributes so we can get a feature's attributes except for the geometry ones
This commit is contained in:
@@ -68,17 +68,23 @@ goog.inherits(ol.Feature, ol.Object);
|
||||
|
||||
/**
|
||||
* Gets a copy of the attributes of this feature.
|
||||
* @param {boolean=} opt_nonGeometry Don't include any geometry attributes
|
||||
* (by default geometry attributes are returned).
|
||||
* @return {Object.<string, *>} Attributes object.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.Feature.prototype.getAttributes = function() {
|
||||
ol.Feature.prototype.getAttributes = function(opt_nonGeometry) {
|
||||
var keys = this.getKeys(),
|
||||
len = keys.length,
|
||||
attributes = {},
|
||||
i, key;
|
||||
for (i = 0; i < len; ++ i) {
|
||||
key = keys[i];
|
||||
attributes[key] = this.get(key);
|
||||
var value = this.get(key);
|
||||
if (!goog.isDef(opt_nonGeometry) || opt_nonGeometry == false ||
|
||||
(opt_nonGeometry === true && !(value instanceof ol.geom.Geometry))) {
|
||||
attributes[key] = value;
|
||||
}
|
||||
}
|
||||
return attributes;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user