diff --git a/examples/modify-features.js b/examples/modify-features.js
index b33a76a5b1..28ae111367 100644
--- a/examples/modify-features.js
+++ b/examples/modify-features.js
@@ -1,4 +1,3 @@
-goog.require('ol.FeatureOverlay');
goog.require('ol.Map');
goog.require('ol.View2D');
goog.require('ol.interaction');
@@ -230,13 +229,12 @@ var overlayStyle = (function() {
var select = new ol.interaction.Select({
style: overlayStyle
});
-var overlay = new ol.FeatureOverlay({
+
+var modify = new ol.interaction.Modify({
features: select.getFeatures(),
style: overlayStyle
});
-var modify = new ol.interaction.Modify({ featureOverlay: overlay });
-
var map = new ol.Map({
interactions: ol.interaction.defaults().extend([select, modify]),
layers: [raster, vectorLayer],
diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc
index 9d318f297b..566108902a 100644
--- a/src/objectliterals.jsdoc
+++ b/src/objectliterals.jsdoc
@@ -454,7 +454,8 @@
* @typedef {Object} olx.interaction.ModifyOptions
* @property {number|undefined} pixelTolerance Pixel tolerance for considering
* the pointer close enough to a vertex for editing. Default is 20 pixels.
- * @property {ol.FeatureOverlay} featureOverlay Features overlay.
+ * @property {ol.style.Style|Array.
|ol.feature.StyleFunction|undefined} style FeatureOverlay style.
+ * @property {ol.Collection} features The features the interaction works on.
*/
/**
diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js
index e1de03bdba..3de50be901 100644
--- a/src/ol/interaction/modifyinteraction.js
+++ b/src/ol/interaction/modifyinteraction.js
@@ -2,6 +2,7 @@ goog.provide('ol.interaction.Modify');
goog.require('goog.array');
goog.require('goog.asserts');
+goog.require('goog.events');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');
goog.require('ol.Feature');
@@ -85,11 +86,19 @@ ol.interaction.Modify = function(options) {
* @type {ol.FeatureOverlay}
* @private
*/
- this.overlay_ = options.featureOverlay;
+ this.overlay_ = new ol.FeatureOverlay({
+ style: options.style
+ });
- this.overlay_.getFeatures().listen(ol.CollectionEventType.ADD,
+ /**
+ * @type {ol.Collection}
+ * @private
+ */
+ this.features_ = options.features;
+
+ goog.events.listen(this.features_, ol.CollectionEventType.ADD,
this.addFeature_, false, this);
- this.overlay_.getFeatures().listen(ol.CollectionEventType.REMOVE,
+ goog.events.listen(this.features_, ol.CollectionEventType.REMOVE,
this.removeFeature_, false, this);
/**
@@ -315,8 +324,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(evt) {
}
// There remains only vertexFeature…
if (!goog.isNull(this.vertexFeature_) &&
- this.overlay_.getFeatures().getLength() === 1 &&
- this.overlay_.getFeatures().getAt(0) == this.vertexFeature_) {
+ this.features_.getLength() === 0) {
this.overlay_.removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}