Support hitTolerance in forEachLayerAtPixel

This commit is contained in:
simonseyock
2017-09-23 15:05:24 +02:00
committed by Tim Schaub
parent 3b64641e5a
commit fcc7d87b06
7 changed files with 100 additions and 22 deletions
+8 -15
View File
@@ -612,29 +612,22 @@ PluggableMap.prototype.getFeaturesAtPixel = function(pixel, opt_options) {
* [R, G, B, A] pixel values (0 - 255) and will be `null` for layer types
* that do not currently support this argument. To stop detection, callback
* functions can return a truthy value.
* @param {S=} opt_this Value to use as `this` when executing `callback`.
* @param {(function(this: U, module:ol/layer/Layer): boolean)=} opt_layerFilter Layer
* filter function. The filter function will receive one argument, the
* {@link module: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.
* @param {U=} opt_this2 Value to use as `this` when executing `layerFilter`.
* @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Configuration 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,U
* @template S,T
* @api
*/
PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this, opt_layerFilter, opt_this2) {
PluggableMap.prototype.forEachLayerAtPixel = function(pixel, callback, opt_options) {
if (!this.frameState_) {
return;
}
const thisArg = opt_this !== undefined ? opt_this : null;
const layerFilter = opt_layerFilter !== undefined ? opt_layerFilter : TRUE;
const thisArg2 = opt_this2 !== undefined ? opt_this2 : null;
const options = opt_options || {};
const hitTolerance = options.hitTolerance !== undefined ?
opt_options.hitTolerance * this.frameState_.pixelRatio : 0;
const layerFilter = options.layerFilter || TRUE;
return this.renderer_.forEachLayerAtPixel(
pixel, this.frameState_, callback, thisArg,
layerFilter, thisArg2);
pixel, this.frameState_, hitTolerance, callback, null, layerFilter, null);
};