Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

376
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda