Avoid clashing with user property names
Features are records with any number of user set values. Separate from this, we rely on feature properties like the feature identifier and feature style. The two (user properties and our internal properties) should not be mixed.
This commit is contained in:
@@ -10,14 +10,6 @@ goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.style.Style');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.FeatureProperty = {
|
||||
STYLE_FUNCTION: 'styleFunction'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -42,6 +34,12 @@ ol.Feature = function(opt_geometryOrValues) {
|
||||
*/
|
||||
this.geometryName_ = 'geometry';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.feature.FeatureStyleFunction|undefined}
|
||||
*/
|
||||
this.styleFunction_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {goog.events.Key}
|
||||
@@ -51,9 +49,6 @@ ol.Feature = function(opt_geometryOrValues) {
|
||||
goog.events.listen(
|
||||
this, ol.Object.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, false, this);
|
||||
goog.events.listen(
|
||||
this, ol.Object.getChangeEventType(ol.FeatureProperty.STYLE_FUNCTION),
|
||||
this.handleStyleFunctionChange_, false, this);
|
||||
|
||||
if (goog.isDefAndNotNull(opt_geometryOrValues)) {
|
||||
if (opt_geometryOrValues instanceof ol.geom.Geometry) {
|
||||
@@ -108,13 +103,8 @@ ol.Feature.prototype.getGeometryName = function() {
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.Feature.prototype.getStyleFunction = function() {
|
||||
return /** @type {ol.feature.FeatureStyleFunction|undefined} */ (
|
||||
this.get(ol.FeatureProperty.STYLE_FUNCTION));
|
||||
return this.styleFunction_;
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Feature.prototype,
|
||||
'getStyleFunction',
|
||||
ol.Feature.prototype.getStyleFunction);
|
||||
|
||||
|
||||
/**
|
||||
@@ -142,14 +132,6 @@ ol.Feature.prototype.handleGeometryChanged_ = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.Feature.prototype.handleStyleFunctionChange_ = function() {
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry|undefined} geometry Geometry.
|
||||
* @todo stability experimental
|
||||
@@ -165,16 +147,13 @@ goog.exportProperty(
|
||||
|
||||
/**
|
||||
* @param {ol.feature.FeatureStyleFunction|undefined} styleFunction Style
|
||||
* function
|
||||
* function.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.Feature.prototype.setStyleFunction = function(styleFunction) {
|
||||
this.set(ol.FeatureProperty.STYLE_FUNCTION, styleFunction);
|
||||
this.styleFunction_ = styleFunction;
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.Feature.prototype,
|
||||
'setStyleFunction',
|
||||
ol.Feature.prototype.setStyleFunction);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user