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

187
Visualizações
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 à 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