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

188
Vistas
Openlayers infinite loop called when clear()

I created the function that enable selection of feature from map, with 2 functions thats are called when I click on feature or when I click on map (no feature selected)

E.G

select = new ol.interaction.Select({
  toggleCondition: this.isMultipleSelectionEnable
    ? null
    : ol.events.condition.never,
  style: selectedStyle
})
this.select = select
map.addInteraction(select)
this.selectedFeatures = select.getFeatures()

Here are my functions

this.selectedFeatures.on(['add'] function() {} // add feature to map) and this.selectedFeatures.on(['remove']function(){this.map.clear())

This works well when I click on my map, but whenever I call the function clear() to clear selectedFeatures from another component, it automaticly calls the 'remove' function from OL, making an infinite loop.

How can I resolve this? How can we can we clear the selected features from the map, without triggering the "remove" function from OL? Or can we call directly the 'remove' from another component?

about 4 years ago · Juan Pablo Isaza
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