Skip to content

Commit

Permalink
Merge layerFilter option into layers
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Apr 29, 2014
1 parent 2c7282d commit 3c308af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
18 changes: 7 additions & 11 deletions externs/olx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1726,8 +1726,7 @@ olx.interaction.PinchZoomOptions.prototype.duration;
/**
* @typedef {{addCondition: (ol.events.ConditionType|undefined),
* condition: (ol.events.ConditionType|undefined),
* layerFilter: (function(ol.layer.Layer): boolean|undefined),
* layers: (Array.<ol.layer.Layer>|undefined),
* layers: (Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction|undefined),
* removeCondition: (ol.events.ConditionType|undefined),
* toggleCondition: (ol.events.ConditionType|undefined)}}
Expand Down Expand Up @@ -1755,15 +1754,12 @@ olx.interaction.SelectOptions.prototype.condition;


/**
* Filter function to restrict selection to a subset of layers.
* @type {function(ol.layer.Layer): boolean|undefined}
*/
olx.interaction.SelectOptions.prototype.layerFilter;


/**
* Layers. Zero or more layers from which features should be selected.
* @type {Array.<ol.layer.Layer>|undefined}
* A list of layers from which features should be
* selected. Alternatively, a filter function can be provided. The
* function will be called for each layer in the map and should return
* `true` for layers that you want to be selectable. If the option is
* absent, all visible layers will be considered selectable.
* @type {Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean|undefined}
*/
olx.interaction.SelectOptions.prototype.layers;

Expand Down
26 changes: 14 additions & 12 deletions src/ol/interaction/selectinteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ ol.interaction.Select = function(opt_options) {
options.toggleCondition : ol.events.condition.shiftKeyOnly;

var layerFilter;
if (goog.isDef(options.layerFilter)) {
layerFilter = options.layerFilter;
} else if (goog.isDef(options.layers)) {
var layers = options.layers;
layerFilter =
/**
* @param {ol.layer.Layer} layer Layer.
* @return {boolean} Include.
*/
function(layer) {
return goog.array.contains(layers, layer);
};
if (goog.isDef(options.layers)) {
if (goog.isFunction(options.layers)) {
layerFilter = options.layers;
} else {
var layers = options.layers;
layerFilter =
/**
* @param {ol.layer.Layer} layer Layer.
* @return {boolean} Include.
*/
function(layer) {
return goog.array.contains(layers, layer);
};
}
} else {
layerFilter = goog.functions.TRUE;
}
Expand Down

0 comments on commit 3c308af

Please sign in to comment.