Added hitTolerance to hasFeatureAtPixel. Corrected JsDoc problems.
This commit is contained in:
@@ -303,39 +303,42 @@ olx.MapOptions.prototype.view;
|
||||
|
||||
|
||||
/**
|
||||
* Object literal with options for the forEachFeatureAtCoordinate methods.
|
||||
* Object literal with options for the forEachFeatureAtPixel and
|
||||
* hasFeatureAtPixel methods.
|
||||
* @typedef {{layerFilter: ((function(ol.layer.Layer): boolean)|undefined),
|
||||
* layerFilterThis: (Object|undefined),
|
||||
* hitTolerance: (number|undefined)}}
|
||||
*/
|
||||
olx.ForEachFeatureOptions;
|
||||
olx.FeatureAtPixelOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Layer filter function. 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.
|
||||
* 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 stable
|
||||
*/
|
||||
olx.ForEachFeatureOptions.prototype.layerFilter;
|
||||
olx.FeatureAtPixelOptions.prototype.layerFilter;
|
||||
|
||||
|
||||
/**
|
||||
* Value to use as `this` when executing `layerFilter`.
|
||||
* @type {Object}
|
||||
* @type {Object|undefined}
|
||||
* @api stable
|
||||
*/
|
||||
olx.ForEachFeatureOptions.prototype.layerFilterThis;
|
||||
olx.FeatureAtPixelOptions.prototype.layerFilterThis;
|
||||
|
||||
|
||||
/**
|
||||
* Value of a radius in whichs area around the given coordinate features are
|
||||
* called.
|
||||
* @type {number}
|
||||
* @api stable
|
||||
* Hit-detection tolerance. Pixels inside the radius around the given position
|
||||
* will be checked for features. This only works for the canvas renderer and
|
||||
* not for WebGL.
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.ForEachFeatureOptions.prototype.hitTolerance;
|
||||
olx.FeatureAtPixelOptions.prototype.hitTolerance;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -568,7 +568,7 @@ ol.Map.prototype.disposeInternal = function() {
|
||||
* unmanaged layers. To stop detection, callback functions can return a
|
||||
* truthy value.
|
||||
* @param {S=} opt_this Value to use as this when executing callback.
|
||||
* @param {olx.ForEachFeatureOptions=} opt_options Optional options.
|
||||
* @param {olx.FeatureAtPixelOptions=} 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
|
||||
@@ -632,27 +632,22 @@ ol.Map.prototype.forEachLayerAtPixel = function(pixel, callback, opt_this, opt_l
|
||||
* Detect if features intersect a pixel on the viewport. Layers included in the
|
||||
* detection can be configured through `opt_layerFilter`.
|
||||
* @param {ol.Pixel} pixel Pixel.
|
||||
* @param {(function(this: U, ol.layer.Layer): boolean)=} opt_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.
|
||||
* @param {U=} opt_this Value to use as `this` when executing `layerFilter`.
|
||||
* @param {olx.FeatureAtPixelOptions=} opt_options Optional options.
|
||||
* @return {boolean} Is there a feature at the given pixel?
|
||||
* @template U
|
||||
* @api
|
||||
*/
|
||||
ol.Map.prototype.hasFeatureAtPixel = function(pixel, opt_layerFilter, opt_this) {
|
||||
ol.Map.prototype.hasFeatureAtPixel = function(pixel, opt_options) {
|
||||
opt_options = opt_options !== undefined ? opt_options : {};
|
||||
if (!this.frameState_) {
|
||||
return false;
|
||||
}
|
||||
var coordinate = this.getCoordinateFromPixel(pixel);
|
||||
var layerFilter = opt_layerFilter !== undefined ?
|
||||
opt_layerFilter : ol.functions.TRUE;
|
||||
var thisArg = opt_this !== undefined ? opt_this : null;
|
||||
var layerFilter = opt_options.layerFilter !== undefined ?
|
||||
opt_options.layerFilter : ol.functions.TRUE;
|
||||
var thisArg = opt_options.layerFilterThis !== undefined ? opt_options.layerFilterThis : null;
|
||||
return this.renderer_.hasFeatureAtCoordinate(
|
||||
coordinate, this.frameState_, layerFilter, thisArg);
|
||||
coordinate, this.frameState_, opt_options.hitTolerance || 0, layerFilter, thisArg);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -189,6 +189,7 @@ ol.renderer.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, call
|
||||
/**
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @param {olx.FrameState} frameState FrameState.
|
||||
* @param {number} hitTolerance HitTolerance.
|
||||
* @param {function(this: U, ol.layer.Layer): boolean} layerFilter Layer filter
|
||||
* function, only layers which are visible and for which this function
|
||||
* returns `true` will be tested for features. By default, all visible
|
||||
@@ -197,9 +198,9 @@ ol.renderer.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, call
|
||||
* @return {boolean} Is there a feature at the given coordinate?
|
||||
* @template U
|
||||
*/
|
||||
ol.renderer.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, layerFilter, thisArg) {
|
||||
ol.renderer.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) {
|
||||
var hasFeature = this.forEachFeatureAtCoordinate(
|
||||
coordinate, frameState, 0, ol.functions.TRUE, this, layerFilter, thisArg);
|
||||
coordinate, frameState, hitTolerance, ol.functions.TRUE, this, layerFilter, thisArg);
|
||||
|
||||
return hasFeature !== undefined;
|
||||
};
|
||||
|
||||
@@ -535,7 +535,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, layerFilter, thisArg) {
|
||||
ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) {
|
||||
var hasFeature = false;
|
||||
|
||||
if (this.getGL().isContextLost()) {
|
||||
|
||||
Reference in New Issue
Block a user