# all files / ol/ interaction.js

100% Statements 42/42
100% Branches 34/34
100% Functions 1/1
100% Lines 42/42

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    1121×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    310×

    310×

    310×

    310×

    310×
    305×

    310×

    310×
    307×

    310×
    310×
    305×

    310×

    310×
    305×

    310×
    310×
    307×

    310×
    310×
    305×
    305×

    310×

    310×
    307×

    310×

    310×
    305×

    310×

     goog.provide('ol.interaction');

    goog.require('ol.Collection');
    goog.require('ol.Kinetic');
    goog.require('ol.interaction.DoubleClickZoom');
    goog.require('ol.interaction.DragPan');
    goog.require('ol.interaction.DragRotate');
    goog.require('ol.interaction.DragZoom');
    goog.require('ol.interaction.KeyboardPan');
    goog.require('ol.interaction.KeyboardZoom');
    goog.require('ol.interaction.MouseWheelZoom');
    goog.require('ol.interaction.PinchRotate');
    goog.require('ol.interaction.PinchZoom');

    /**
     * Set of interactions included in maps by default. Specific interactions can be
     * excluded by setting the appropriate option to false in the constructor
     * options, but the order of the interactions is fixed.  If you want to specify
     * a different order for interactions, you will need to create your own
     * {@link ol.interaction.Interaction} instances and insert them into a
     * {@link ol.Collection} in the order you want before creating your
     * {@link ol.Map} instance. The default set of interactions, in sequence, is:
     * * {@link ol.interaction.DragRotate}
     * * {@link ol.interaction.DoubleClickZoom}
     * * {@link ol.interaction.DragPan}
     * * {@link ol.interaction.PinchRotate}
     * * {@link ol.interaction.PinchZoom}
     * * {@link ol.interaction.KeyboardPan}
     * * {@link ol.interaction.KeyboardZoom}
     * * {@link ol.interaction.MouseWheelZoom}
     * * {@link ol.interaction.DragZoom}
     *
     * @param {olx.interaction.DefaultsOptions=} opt_options Defaults options.
     * @return {ol.Collection.<ol.interaction.Interaction>} A collection of
     * interactions to be used with the ol.Map constructor's interactions option.
     * @api
     */
    ol.interaction.defaults = function(opt_options) {

      var options = opt_options ? opt_options : {};

      var interactions = new ol.Collection();

      var kinetic = new ol.Kinetic(-0.005, 0.05, 100);

      var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
        options.altShiftDragRotate : true;
      if (altShiftDragRotate) {
        interactions.push(new ol.interaction.DragRotate());
      }

      var doubleClickZoom = options.doubleClickZoom !== undefined ?
        options.doubleClickZoom : true;
      if (doubleClickZoom) {
        interactions.push(new ol.interaction.DoubleClickZoom({
          delta: options.zoomDelta,
          duration: options.zoomDuration
        }));
      }

      var dragPan = options.dragPan !== undefined ? options.dragPan : true;
      if (dragPan) {
        interactions.push(new ol.interaction.DragPan({
          kinetic: kinetic
        }));
      }

      var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
        true;
      if (pinchRotate) {
        interactions.push(new ol.interaction.PinchRotate());
      }

      var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
      if (pinchZoom) {
        interactions.push(new ol.interaction.PinchZoom({
          constrainResolution: options.constrainResolution,
          duration: options.zoomDuration
        }));
      }

      var keyboard = options.keyboard !== undefined ? options.keyboard : true;
      if (keyboard) {
        interactions.push(new ol.interaction.KeyboardPan());
        interactions.push(new ol.interaction.KeyboardZoom({
          delta: options.zoomDelta,
          duration: options.zoomDuration
        }));
      }

      var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
        options.mouseWheelZoom : true;
      if (mouseWheelZoom) {
        interactions.push(new ol.interaction.MouseWheelZoom({
          constrainResolution: options.constrainResolution,
          duration: options.zoomDuration
        }));
      }

      var shiftDragZoom = options.shiftDragZoom !== undefined ?
        options.shiftDragZoom : true;
      if (shiftDragZoom) {
        interactions.push(new ol.interaction.DragZoom({
          duration: options.zoomDuration
        }));
      }

      return interactions;

    };