Merge pull request #6680 from fredj/rm_ol.DRAG_BOX_HYSTERESIS_PIXELS
Remove ol.DRAG_BOX_HYSTERESIS_PIXELS define and add option
This commit is contained in:
+12
-11
@@ -2550,6 +2550,7 @@ olx.interaction.DragAndDropOptions.prototype.target;
|
|||||||
/**
|
/**
|
||||||
* @typedef {{className: (string|undefined),
|
* @typedef {{className: (string|undefined),
|
||||||
* condition: (ol.EventsConditionType|undefined),
|
* condition: (ol.EventsConditionType|undefined),
|
||||||
|
* minArea: (number|undefined),
|
||||||
* boxEndCondition: (ol.DragBoxEndConditionType|undefined)}}
|
* boxEndCondition: (ol.DragBoxEndConditionType|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.interaction.DragBoxOptions;
|
olx.interaction.DragBoxOptions;
|
||||||
@@ -2573,19 +2574,19 @@ olx.interaction.DragBoxOptions.prototype.className;
|
|||||||
olx.interaction.DragBoxOptions.prototype.condition;
|
olx.interaction.DragBoxOptions.prototype.condition;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum area of the box in pixel, this value is used by the default
|
||||||
|
* `boxEndCondition` function. Default is `64`.
|
||||||
|
* @type {number|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.interaction.DragBoxOptions.prototype.minArea;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that takes a {@link ol.MapBrowserEvent} and two
|
* A function that takes a {@link ol.MapBrowserEvent} and two
|
||||||
* {@link ol.Pixel}s to indicate whether a boxend event should be fired.
|
* {@link ol.Pixel}s to indicate whether a `boxend` event should be fired.
|
||||||
* Default is:
|
* Default is `true` if the area of the box is bigger than the `minArea` option.
|
||||||
* ```js
|
|
||||||
* function(mapBrowserEvent,
|
|
||||||
* startPixel, endPixel) {
|
|
||||||
* var width = endPixel[0] - startPixel[0];
|
|
||||||
* var height = endPixel[1] - startPixel[1];
|
|
||||||
* return width * width + height * height >=
|
|
||||||
* ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED;
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @type {ol.DragBoxEndConditionType|undefined}
|
* @type {ol.DragBoxEndConditionType|undefined}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,12 +47,6 @@ ol.DEFAULT_TILE_SIZE = 256;
|
|||||||
ol.DEFAULT_WMS_VERSION = '1.3.0';
|
ol.DEFAULT_WMS_VERSION = '1.3.0';
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {number} Hysteresis pixels.
|
|
||||||
*/
|
|
||||||
ol.DRAG_BOX_HYSTERESIS_PIXELS = 8;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @define {boolean} Enable the Canvas renderer. Default is `true`. Setting
|
* @define {boolean} Enable the Canvas renderer. Default is `true`. Setting
|
||||||
* this to false at compile time in advanced mode removes all code
|
* this to false at compile time in advanced mode removes all code
|
||||||
|
|||||||
@@ -8,15 +8,6 @@ goog.require('ol.interaction.Pointer');
|
|||||||
goog.require('ol.render.Box');
|
goog.require('ol.render.Box');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED =
|
|
||||||
ol.DRAG_BOX_HYSTERESIS_PIXELS *
|
|
||||||
ol.DRAG_BOX_HYSTERESIS_PIXELS;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* Allows the user to draw a vector box by clicking and dragging on the map,
|
* Allows the user to draw a vector box by clicking and dragging on the map,
|
||||||
@@ -50,6 +41,12 @@ ol.interaction.DragBox = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.box_ = new ol.render.Box(options.className || 'ol-dragbox');
|
this.box_ = new ol.render.Box(options.className || 'ol-dragbox');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.minArea_ = options.minArea !== undefined ? options.minArea : 64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Pixel}
|
* @type {ol.Pixel}
|
||||||
* @private
|
* @private
|
||||||
@@ -76,18 +73,16 @@ ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
|
|||||||
/**
|
/**
|
||||||
* The default condition for determining whether the boxend event
|
* The default condition for determining whether the boxend event
|
||||||
* should fire.
|
* should fire.
|
||||||
* @param {ol.MapBrowserEvent} mapBrowserEvent The originating MapBrowserEvent
|
* @param {ol.MapBrowserEvent} mapBrowserEvent The originating MapBrowserEvent
|
||||||
* leading to the box end.
|
* leading to the box end.
|
||||||
* @param {ol.Pixel} startPixel The starting pixel of the box.
|
* @param {ol.Pixel} startPixel The starting pixel of the box.
|
||||||
* @param {ol.Pixel} endPixel The end pixel of the box.
|
* @param {ol.Pixel} endPixel The end pixel of the box.
|
||||||
* @return {boolean} Whether or not the boxend condition should be fired.
|
* @return {boolean} Whether or not the boxend condition should be fired.
|
||||||
*/
|
*/
|
||||||
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent,
|
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) {
|
||||||
startPixel, endPixel) {
|
|
||||||
var width = endPixel[0] - startPixel[0];
|
var width = endPixel[0] - startPixel[0];
|
||||||
var height = endPixel[1] - startPixel[1];
|
var height = endPixel[1] - startPixel[1];
|
||||||
return width * width + height * height >=
|
return width * width + height * height >= this.minArea_;
|
||||||
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user