1

I use this part of code to make all layers selectable:

this.selectFeaturesClick = new Select({
  style: selectFeatureStyle,
  condition: click,
  multi: false,
  filter: (feature: FeatureLike) => {
    console.log(feature);

    return (
      !this.drawingService.editFeaturePoint &&
      feature.getGeometry().getType() !== LayerType.point
    );
  },
});

The issue is I got all layers selected after click. How to make only top layers selected? This console.log(feature); showesme two messages by count of visible layers.

1 Answer 1

2

Either specify the layer in the layers option

  layers: [topLayer],

or test the layer in the filter function

  filter: (feature, layer) => {
    return (
      !this.drawingService.editFeaturePoint &&
      feature.getGeometry().getType() !== LayerType.point &&
      layer === topLayer
    );
  },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.