From 620a38d3e98ce1c5eade0b76958e4fa101c09e6d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 7 Feb 2014 16:35:54 -0700 Subject: [PATCH] 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. --- src/ol/feature.js | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/src/ol/feature.js b/src/ol/feature.js index 77d35aa333..c2154c6974 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -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); /**