Exclude unmanaged layers from selection
This commit is contained in:
@@ -283,7 +283,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) {
|
|||||||
* @param {ol.layer.Layer} layer Layer.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
*/
|
*/
|
||||||
function(feature, layer) {
|
function(feature, layer) {
|
||||||
if (this.filter_(feature, layer)) {
|
if (layer && this.filter_(feature, layer)) {
|
||||||
selected.push(feature);
|
selected.push(feature);
|
||||||
this.addFeatureLayerAssociation_(feature, layer);
|
this.addFeatureLayerAssociation_(feature, layer);
|
||||||
return !this.multi_;
|
return !this.multi_;
|
||||||
|
|||||||
@@ -161,6 +161,29 @@ describe('ol.interaction.Select', function() {
|
|||||||
describe('filter features using the filter option', function() {
|
describe('filter features using the filter option', function() {
|
||||||
var select;
|
var select;
|
||||||
|
|
||||||
|
describe('with unmanaged layers', function() {
|
||||||
|
it('does not call filter for unmanaged layers', function() {
|
||||||
|
var spy = sinon.spy();
|
||||||
|
var select = new ol.interaction.Select({
|
||||||
|
multi: false,
|
||||||
|
filter: spy
|
||||||
|
});
|
||||||
|
map.addInteraction(select);
|
||||||
|
var feature = new ol.Feature(
|
||||||
|
new ol.geom.Polygon([[[0, 0], [0, 40], [40, 40], [40, 0]]]));
|
||||||
|
var unmanaged = new ol.layer.Vector({
|
||||||
|
source: new ol.source.Vector({
|
||||||
|
features: [feature]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
unmanaged.setMap(map);
|
||||||
|
map.renderSync();
|
||||||
|
simulateEvent(ol.MapBrowserEvent.EventType.SINGLECLICK, 10, -20);
|
||||||
|
expect(spy.firstCall.args[0]).to.not.equal(feature);
|
||||||
|
unmanaged.setMap(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('with multi set to true', function() {
|
describe('with multi set to true', function() {
|
||||||
|
|
||||||
it('only selects features that pass the filter', function() {
|
it('only selects features that pass the filter', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user