Search code examples
openlayers-3

Listen for end of translation using ol.interaction.Translate


I'm playing with the new Translate interaction (ol.interaction.Translate) added in v3.9.0. I am wondering if there is a way to listen for an event notifying the end of the translation?


Solution

  • There is a new event now : translateend

    const myTanslate = new ol.interaction.Translate({
      layers: [myLayer],
    })
    
    myTanslate.on('translateend', evt => {
      evt.features.forEach(feat => {
        // process every feature
      })
    })
    

    PS edit: don't forget to add interaction to your map with map.addInteraction(myTanslate)