O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – configuring default interactions

Let's deactivate zoom and pan with the keyboard and also the rotate when doing Alt + Shift + mouse drag.

For this, do the following:

  1. Copy the usual HTML file.
  2. Add in the block <div id="map" class="map"></div> the attribute tabIndex with a value 0 to make it focusable.
  3. Change the keyboard option to false in the interactions property of the ol.Map object.
  4. Do all this with the altShiftDragRotate option. Try different actions with the left, right, up, and down arrows or with the plus and minus keys.
  5. Do all this by trying to use Alt + Shift + mouse drag.

What just happened?

Here you just saw an example to deactivate some default behaviors.

By changing keyboard options to false, we make the application unable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required