Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

373
Views
OpenLayers 6, iterar a través de todas las características de una capa?

En OpenLayers 6...

No estoy familiarizado con la cosa, pero... ¿Cómo puedo iterar a través de todas las funciones en mi capa con el título "firmenGeoJSON" y ocultar o mostrar algunas de ellas con la propiedad específica "nombre"?

Gracias...

 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 answers
Answer question

0

Para iterar a través de todas las características de una capa, primero debe obtener su origen:

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

Aunque si desea mostrar u ocultar características, puede ser mejor hacerlo en una función de estilo de capa:

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

Pero tenga en cuenta que una función de estilo de capa solo se llama si la función en sí no tiene un conjunto de estilos. En ese caso, considere cambiar a una función de estilo de capa, como se ve arriba.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!