From f306fd0aa0552749aec99feadb6f6b9854b10216 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sun, 11 Mar 2018 10:30:02 -0600 Subject: [PATCH] Move AtPixelOptions to PluggableMap --- externs/olx.js | 32 +------------------------------- externs/xol.js | 12 ------------ src/ol/PluggableMap.js | 19 ++++++++++++++++--- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 0d7370bdb1..949efbb640 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2,37 +2,7 @@ /** * @type {Object} */ -var olx; - - -/** - * Object literal with options for the {@link ol.Map#forEachFeatureAtPixel} and - * {@link ol.Map#hasFeatureAtPixel} methods. - * @typedef {{layerFilter: ((function(ol.layer.Layer): boolean)|undefined), - * hitTolerance: (number|undefined)}} - */ -olx.AtPixelOptions; - - -/** - * Layer filter function. The filter function will receive one argument, the - * {@link ol.layer.Layer layer-candidate} and it should return a boolean value. - * Only layers which are visible and for which this function returns `true` - * will be tested for features. By default, all visible layers will be tested. - * @type {((function(ol.layer.Layer): boolean)|undefined)} - * @api - */ -olx.AtPixelOptions.prototype.layerFilter; - - -/** - * Hit-detection tolerance in pixels. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.AtPixelOptions.prototype.hitTolerance; +let olx; /** diff --git a/externs/xol.js b/externs/xol.js index 927a41f525..129fafce20 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,16 +1,4 @@ -/** - * @typedef {Object} AtPixelOptions - * @property {((function(ol.layer.Layer): boolean)|undefined)} layerFilter Layer filter function. The filter function will receive one argument, the - * {@link ol.layer.Layer layer-candidate} and it should return a boolean value. - * Only layers which are visible and for which this function returns `true` - * will be tested for features. By default, all visible layers will be tested. - * @property {number|undefined} hitTolerance Hit-detection tolerance in pixels. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - */ - - /** * @typedef {Object} ProjectionOptions * @property {string} code The SRS identifier code, e.g. `EPSG:4326`. diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 41d518ca16..9978248f20 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -61,6 +61,19 @@ import {create as createTransform, apply as applyTransform} from './transform.js */ +/** + * @typedef {Object} AtPixelOptions + * @property {((function(ol.layer.Layer): boolean)|undefined)} layerFilter Layer filter + * function. The filter function will receive one argument, the + * {@link ol.layer.Layer layer-candidate} and it should return a boolean value. + * Only layers which are visible and for which this function returns `true` + * will be tested for features. By default, all visible layers will be tested. + * @property {number|undefined} hitTolerance Hit-detection tolerance in pixels. Pixels + * inside the radius around the given position will be checked for features. This only + * works for the canvas renderer and not for WebGL. Default is `0`. + */ + + /** * @typedef {Object} MapOptionsInternal * @property {module:ol/Collection~Collection.} [controls] @@ -554,7 +567,7 @@ PluggableMap.prototype.disposeInternal = function() { * the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for * unmanaged layers. To stop detection, callback functions can return a * truthy value. - * @param {olx.AtPixelOptions=} opt_options Optional options. + * @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options. * @return {T|undefined} Callback result, i.e. the return value of last * callback execution, or the first truthy callback return value. * @template S,T @@ -579,7 +592,7 @@ PluggableMap.prototype.forEachFeatureAtPixel = function(pixel, callback, opt_opt /** * Get all features that intersect a pixel on the viewport. * @param {module:ol~Pixel} pixel Pixel. - * @param {olx.AtPixelOptions=} opt_options Optional options. + * @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options. * @return {Array.} The detected features or * `null` if none were found. * @api @@ -636,7 +649,7 @@ PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this, * Detect if features intersect a pixel on the viewport. Layers included in the * detection can be configured through `opt_layerFilter`. * @param {module:ol~Pixel} pixel Pixel. - * @param {olx.AtPixelOptions=} opt_options Optional options. + * @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options. * @return {boolean} Is there a feature at the given pixel? * @template U * @api