Store the feature's commonly used id

To not clobber the feature's attributes, this is a separate
member property.
This commit is contained in:
ahocevar
2013-05-23 11:16:17 -05:00
parent d1beaff8e4
commit 8c0f1f979a
6 changed files with 42 additions and 1 deletions

View File

@@ -14,6 +14,12 @@ ol.Feature = function(opt_values) {
goog.base(this, opt_values);
/**
* @type {string|undefined}
* @private
*/
this.featureId_;
/**
* @type {string|undefined}
* @private
@@ -46,6 +52,17 @@ ol.Feature.prototype.getAttributes = function() {
};
/**
* Returns the feature's commonly used identifier. This identifier is usually
* the unique id in the source store.
*
* @return {string|undefined} The feature's identifier.
*/
ol.Feature.prototype.getFeatureId = function() {
return this.featureId_;
};
/**
* @return {ol.geom.Geometry} The geometry (or null if none).
*/
@@ -85,6 +102,17 @@ ol.Feature.prototype.set = function(key, value) {
};
/**
* Set the feature's commonly used identifier. This identifier is usually the
* unique id in the source store.
*
* @param {string} featureId The feature's identifier.
*/
ol.Feature.prototype.setFeatureId = function(featureId) {
this.featureId_ = featureId;
};
/**
* @param {ol.geom.Geometry} geometry The geometry.
*/