Atlaslog
Atlaslog / OpenLayers / API reference / Interaction
OpenLayers · API reference

Interaction

Quick answer

Interaction is ol.interaction.Interaction, the base class for every mouse and touch behavior on a map. Its active option and setActive method enable or disable a handler, while handleEvent decides whether an event is consumed and stops propagation. Extend Pointer or Interaction to build custom gestures, then register with map.addInteraction.

Last verified 2026-11-03 · OpenLayers 10.3.1 · Cite this page
new ol.interaction.Interaction( options )
Key points
Example
map.getInteractions().forEach(function (interaction) {
  if (interaction instanceof ol.interaction.DoubleClickZoom) {
    interaction.setActive(false);
  }
});
var dragBox = new ol.interaction.DragBox({
  condition: function (evt) { return evt.originalEvent.shiftKey; }
});
map.addInteraction(dragBox);

dragBox.on('boxend', function () {
  console.log(dragBox.getGeometry().getExtent());
});
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Interaction. https://www.jingweizhi.com/en/openlayers/api/interaction.html (accessed 2026-11-03).