I'm trying to build a popup that only shows feature info from certain layers. How do I get layer name?

I've tried this:

const features = this.map.getFeaturesAtPixel(evt.pixel, {
  layerFilter: ((layerCandidate: layer.Layer) => {
    if (layerCandidate.get('name') === 'my layer') {
      return true;
    return false;
var feature = Map.olMap.forEachFeatureAtPixel(pixel, function (feature, layer) {
                    options.layer = layer;
                    options.features = feature;
                    options.modify = self.currentInteraction;
                    options.sender = self;

In these codes, you can get all layer properties with this command


title, opacity, visible and other details about layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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