diff --git a/src/ol/feature.js b/src/ol/feature.js index 69ca5aea0d..ad4465cce4 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -51,20 +51,6 @@ ol.Feature = function(opt_values) { goog.inherits(ol.Feature, ol.Object); -/** - * Create a clone of this feature. Both the feature and its geometry will be - * cloned. - * @return {ol.Feature} A clone of this feature, with a cloned geometry. - */ -ol.Feature.prototype.clone = function() { - var clone = new ol.Feature(this.getAttributes()); - clone.setGeometry(this.getGeometry().clone()); - clone.featureId_ = this.featureId_; - clone.symbolizers_ = this.symbolizers_; - return clone; -}; - - /** * Gets a copy of the attributes of this feature. * @return {Object.} Attributes object. @@ -130,7 +116,7 @@ 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. + * @param {string|undefined} featureId The feature's identifier. */ ol.Feature.prototype.setFeatureId = function(featureId) { this.featureId_ = featureId; diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 7b44ad03f0..559f8b1b39 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -162,9 +162,12 @@ ol.interaction.Select.prototype.select = featuresToRemove.push(clone); delete featureMap[featureId]; } else if (!(featureId in oldFeatureMap)) { - clone = feature.clone(); - featureMap[featureId] = clone; + clone = new ol.Feature(feature.getAttributes()); + clone.setGeometry(feature.getGeometry().clone()); + clone.setFeatureId(feature.getFeatureId()); + clone.setSymbolizers(feature.getSymbolizers()); clone.renderIntent = ol.layer.VectorLayerRenderIntent.SELECTED; + featureMap[featureId] = clone; selectedFeatures.push(feature); featuresToAdd.push(clone); } diff --git a/test/spec/ol/feature.test.js b/test/spec/ol/feature.test.js index fb31212579..12ae10ba37 100644 --- a/test/spec/ol/feature.test.js +++ b/test/spec/ol/feature.test.js @@ -34,24 +34,6 @@ describe('ol.Feature', function() { }); - describe('#clone()', function() { - - it('creates a clone with a cloned geometry', function() { - var feature = new ol.Feature({ - loc: new ol.geom.Point([10, 20]), - foo: 'bar' - }); - feature.setFeatureId('foo'); - var clone = feature.clone(); - expect(clone).to.not.be(feature); - expect(clone.get('foo')).to.be('bar'); - expect(clone.getFeatureId()).to.be('foo'); - expect(clone.getGeometry()).to.not.be(feature.getGeometry()); - expect(clone.getGeometry().getCoordinates()).to.eql([10, 20]); - }); - - }); - describe('#get()', function() { it('returns values set at construction', function() {