• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

138
Views
Openlayers on select function not always triggering

I have a map, with features that are recreated every 1 second. (layer is deleted, and recreated, with new features, new coords)

I have a function that create selection :

       selectInteraction = new Select({
          toggleCondition: this.isMultipleSelectionEnable
            ? null
            : ol.events.condition.never,

          style: self.selectedFeatureStyle,
          // and so on...
         }

        this.selectInteraction.on(['select'], function (e) {
          console.log('on select')
          self.parentRef.list.goToItem()
        })

and as you can see, on feature select, I call a method (on ref component, passed as props) that find and scroll to the selected item in a list, which is the same as selected in map. This is working like a charm, but this function is not always triggered whenever I select a feature.

I click on a feature, I have the selected feature style and everything that is related to selection, but this "this.selectInteraction.on(['select']" is not always triggering.

It's like the behaviour is really random, I can click 2 times on a same feature and have no trigger of the function, but the 3rd click will trigger it. I can click once on a feature and have the trigger, and deselect/reselect the same feature and it won't work.

If anyone has an idea why this function is not always fired on selection, that would be great, and if you need any additionnal informations, feel free to ask

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error