diff --git a/src/ol/interaction/modify.js b/src/ol/interaction/modify.js index afa57f6966..b0cbd8a740 100644 --- a/src/ol/interaction/modify.js +++ b/src/ol/interaction/modify.js @@ -248,7 +248,7 @@ ol.inherits(ol.interaction.Modify, ol.interaction.Pointer); */ ol.interaction.Modify.prototype.addFeature_ = function(feature) { var geometry = feature.getGeometry(); - if (geometry.getType() in this.SEGMENT_WRITERS_) { + if (geometry && geometry.getType() in this.SEGMENT_WRITERS_) { this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry); } var map = this.getMap(); diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index cf77f81077..a21d2b50c5 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -162,6 +162,22 @@ describe('ol.interaction.Modify', function() { expect(rbushEntries.length).to.be(1); expect(rbushEntries[0].feature).to.be(feature); }); + + it('accepts feature without geometry', function() { + var feature = new ol.Feature(); + var features = new ol.Collection([feature]); + var modify = new ol.interaction.Modify({ + features: features + }); + var rbushEntries = modify.rBush_.getAll(); + expect(rbushEntries.length).to.be(0); + + feature.setGeometry(new ol.geom.Point([0, 10])); + rbushEntries = modify.rBush_.getAll(); + expect(rbushEntries.length).to.be(1); + expect(rbushEntries[0].feature).to.be(feature); + }); + }); describe('vertex deletion', function() {