Add a "features" option to ol.interaction.Select
This commit is contained in:
@@ -2779,6 +2779,7 @@ olx.interaction.PointerOptions.prototype.handleUpEvent;
|
||||
* removeCondition: (ol.events.ConditionType|undefined),
|
||||
* toggleCondition: (ol.events.ConditionType|undefined),
|
||||
* multi: (boolean|undefined),
|
||||
* features: (ol.Collection.<ol.Feature>|undefined),
|
||||
* filter: (ol.interaction.SelectFilterFunction|undefined),
|
||||
* wrapX: (boolean|undefined)}}
|
||||
* @api
|
||||
@@ -2869,6 +2870,17 @@ olx.interaction.SelectOptions.prototype.toggleCondition;
|
||||
olx.interaction.SelectOptions.prototype.multi;
|
||||
|
||||
|
||||
/**
|
||||
* Collection where the interaction will place selected features. Optional. If
|
||||
* not set the interaction will create a collection. In any case the collection
|
||||
* used by the interaction is returnd by
|
||||
* {@link ol.interaction.Select#getFeatures}.
|
||||
* @type {ol.Collection.<ol.Feature>}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.SelectOptions.prototype.features;
|
||||
|
||||
|
||||
/**
|
||||
* A function that takes an {@link ol.Feature} and an {@link ol.layer.Layer} and
|
||||
* returns `true` if the feature may be selected or `false` otherwise.
|
||||
|
||||
@@ -180,6 +180,7 @@ ol.interaction.Select = function(opt_options) {
|
||||
this.featureOverlay_ = new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
useSpatialIndex: false,
|
||||
features: options.features,
|
||||
wrapX: options.wrapX
|
||||
}),
|
||||
style: goog.isDef(options.style) ? options.style :
|
||||
|
||||
@@ -98,6 +98,16 @@ describe('ol.interaction.Select', function() {
|
||||
expect(select).to.be.a(ol.interaction.Interaction);
|
||||
});
|
||||
|
||||
describe('user-provided collection', function() {
|
||||
|
||||
it('uses the user-provided collection', function() {
|
||||
var features = new ol.Collection();
|
||||
var select = new ol.interaction.Select({features: features});
|
||||
expect(select.getFeatures()).to.be(features);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('selecting a polygon', function() {
|
||||
@@ -269,6 +279,7 @@ goog.require('goog.dispose');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.BrowserEvent');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.MapBrowserEvent.EventType');
|
||||
|
||||
Reference in New Issue
Block a user