TransWikia.com

Getting layer name from getFeaturesAtPixel in OL4

Geographic Information Systems Asked by daudihus on January 3, 2021

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;
  }
  )});`

One Answer

var feature = Map.olMap.forEachFeatureAtPixel(pixel, function (feature, layer) {
                    options.layer = layer;
                    options.features = feature;
                    options.modify = self.currentInteraction;
                    options.sender = self;
                    callback(options);
                });

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

options.layer.getProperties()

title, opacity, visible and other details about layer.

Answered by Ömür Bilgili on January 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP