# all files / ol/interaction/ doubleclickzoominteraction.js

66.67% Statements 16/24
50% Branches 5/10
100% Functions 2/2
66.67% Lines 16/24

    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
    671×

    1×
    1×
    1×
    1×

    1×

    118×

    118×

    118×

    118×

    1×

    1×
    205×
    205×
    205×

    205×

     goog.provide('ol.interaction.DoubleClickZoom');

    goog.require('goog.asserts');
    goog.require('ol.MapBrowserEvent');
    goog.require('ol.MapBrowserEvent.EventType');
    goog.require('ol.interaction.Interaction');

    /**
     * @classdesc
     * Allows the user to zoom by double-clicking on the map.
     *
     * @constructor
     * @extends {ol.interaction.Interaction}
     * @param {olx.interaction.DoubleClickZoomOptions=} opt_options Options.
     * @api stable
     */
    ol.interaction.DoubleClickZoom = function(opt_options) {

      var options = opt_options ? opt_options : {};

      /**
       * @private
       * @type {number}
       */
      this.delta_ = options.delta ? options.delta : 1;

      goog.base(this, {
        handleEvent: ol.interaction.DoubleClickZoom.handleEvent
      });

      /**
       * @private
       * @type {number}
       */
      this.duration_ = options.duration !== undefined ? options.duration : 250;

    };
    goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);

    /**
     * Handles the {@link ol.MapBrowserEvent map browser event} (if it was a
     * doubleclick) and eventually zooms the map.
     * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
     * @return {boolean} `false` to stop event propagation.
     * @this {ol.interaction.DoubleClickZoom}
     * @api
     */
    ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
      var stopEvent = false;
      var browserEvent = mapBrowserEvent.browserEvent;
      Iif (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DBLCLICK) {
        var map = mapBrowserEvent.map;
        var anchor = mapBrowserEvent.coordinate;
        var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
        var view = map.getView();
        goog.asserts.assert(view, 'map must have a view');
        ol.interaction.Interaction.zoomByDelta(
            map, view, delta, anchor, this.duration_);
        mapBrowserEvent.preventDefault();
        stopEvent = true;
      }
      return !stopEvent;
    };