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

178
Views
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
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!