diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 289dedd51f..840cbb3584 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -311,9 +311,12 @@ /** * @typedef {Object} ol.interaction.SelectOptions + * @property {ol.interaction.ConditionType|undefined} addCondition A conditional + * modifier (e.g. shift key) that determines if the selection is added to + * the current selection. Default is when holding the shift key only. * @property {ol.interaction.ConditionType|undefined} condition A conditional - * modifier (i.e. Shift key) that determines if the interaction is active - * or not, default is on mouse click only. + * modifier (e.g. shift key) that determines if the interaction is active + * (i.e. selection occurs) or not. Default is on mouse click only. * @property {undefined|function(ol.layer.Layer):boolean} layerFilter Filter * function to restrict selection to a subset of layers. */ diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index ee157b5049..813e6d1e0f 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -28,6 +28,13 @@ ol.interaction.Select = function(opt_options) { this.condition_ = goog.isDef(options.condition) ? options.condition : ol.interaction.condition.clickOnly; + /** + * @private + * @type {ol.interaction.ConditionType} + */ + this.addCondition_ = goog.isDef(options.addCondition) ? + options.addCondition : ol.interaction.condition.shiftKeyOnly; + /** * Mapping between original features and cloned features on selection layers. * @type {Object.<*,Object.<*,ol.Feature>>} @@ -65,7 +72,7 @@ ol.interaction.Select.prototype.handleMapBrowserEvent = if (!goog.isNull(this.layerFilter_)) { layers = goog.array.filter(layers, this.layerFilter_); } - var clear = !ol.interaction.condition.shiftKeyOnly(mapBrowserEvent); + var clear = !this.addCondition_(mapBrowserEvent); var that = this; var select = function(featuresByLayer) {