How can I easily add/remove interaction in OpenLayers 4?

I need to add:

  • get layer Info as default (WMS feature on OL2)
  • Measure tool. (Already implemented OpenLayers4 stop interaction but I need an easy way to activate/deactivate the feature)
  • Plot a map marker.
  • Draw a circle.
  • Draw a polygon.

Here a demo with OL2 of what I need to do.


What I need to know if exist some kind of add feature based on which button I click and when I finish with this action (just one interaction) return automatically to the default interaction.


  • the default is getInfo.
  • click on draw a circle button
  • the feature is activate
  • I draw the circle
  • automatically the draw feature is removed and getInfo is turn on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.