Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
OpenLayers 6, Iterate through all features of a layer?

In OpenLayers 6...

I'm not familiar with the thing, but... How can I iterate through all features on my layer with the title "firmenGeoJSON" and hide or show some of them with specific property "name"?

Thank you...

let myLayers = map.getAllLayers();

myLayers.forEach(function(layer) {
    if (layer.getProperties()['title'] == 'firmenGeoJSON') {
        console.log('found and hide');
        //??????????
    };
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To iterate through all features of a layer you need to get its source first:

layer.getSource().forEachFeature(function (feature) {
    console.log(feature);
});

Though if you want to show or hide features it may be better to do this in a layer style function:

import {Circle, Fill, Stroke, Style} from './style.js';

const style = new Style({
    image: new Circle({
        radius: 8,
        fill: new Fill({
            color: 'blue',
        }),
    }),
    stroke: new Stroke({
        width: 4,
        color: 'green',
    }),
});
layer.setStyle(function (feature, resolution) {
    if (feature.get('hidden')) {
        return undefined;
    }
    return style;
});

But note that a layer style function is only called if the Feature itself has no Style set. In that case consider switching to a layer style function, as seen above.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda