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 – using ol.interaction.DragRotateAndZoom

Let's follow the component's self-explaining name to try out it behaviour :

  1. First, duplicate the code from the previous ol.interaction.defaults sample.
  2. Then, make changes in the interactions block in the ol.Map object as follows:
    var map = new ol.Map({
      ...
      interactions: ol.interaction.defaults({
        shiftDragZoom: false
      }).extend([new ol.interaction.DragRotateAndZoom()]),
      ...
    });
  3. Finally, open your browser and drag while maintaining the keyboard on the Shift key.

What just happened?

First, as it can conflict with ol.interaction.DragRotateAndZoom, we deactivated the shiftDragZoom interaction by setting it to false. We chose this option, but it was also possible to change the key to activate the function ...

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