Code coverage report for ol/interaction/dragzoominteraction.js

Statements: 66.67% (16 / 24)      Branches: 50% (4 / 8)      Functions: 50% (1 / 2)      Lines: 66.67% (16 / 24)      Ignored: none     

All files » ol/interaction/ » dragzoominteraction.js
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 711   1 1 1 1 1 1 1                             1 80   80             80           80             80           1           1                        
goog.provide('ol.interaction.DragZoom');
 
goog.require('goog.asserts');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.interaction.DragBox');
goog.require('ol.interaction.Interaction');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
 
 
 
/**
 * @classdesc
 * Allows the user to zoom the map by clicking and dragging on the map,
 * normally combined with an {@link ol.events.condition} that limits
 * it to when a key, shift by default, is held down.
 *
 * @constructor
 * @extends {ol.interaction.DragBox}
 * @param {olx.interaction.DragZoomOptions=} opt_options Options.
 * @api stable
 */
ol.interaction.DragZoom = function(opt_options) {
  var options = goog.isDef(opt_options) ? opt_options : {};
 
  var condition = goog.isDef(options.condition) ?
      options.condition : ol.events.condition.shiftKeyOnly;
 
  /**
   * @private
   * @type {number}
   */
  this.duration_ = goog.isDef(options.duration) ? options.duration : 200;
 
  /**
   * @private
   * @type {ol.style.Style}
   */
  var style = goog.isDef(options.style) ?
      options.style : new ol.style.Style({
        stroke: new ol.style.Stroke({
          color: [0, 0, 255, 1]
        })
      });
 
  goog.base(this, {
    condition: condition,
    style: style
  });
 
};
goog.inherits(ol.interaction.DragZoom, ol.interaction.DragBox);
 
 
/**
 * @inheritDoc
 */
ol.interaction.DragZoom.prototype.onBoxEnd = function() {
  var map = this.getMap();
  var view = map.getView();
  goog.asserts.assert(!goog.isNull(view), 'view should not be null');
  var extent = this.getGeometry().getExtent();
  var center = ol.extent.getCenter(extent);
  var size = map.getSize();
  goog.asserts.assert(goog.isDef(size), 'size should be defined');
  ol.interaction.Interaction.zoom(map, view,
      view.getResolutionForExtent(extent, size),
      center, this.duration_);
};