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),
|
* @typedef {{layerFilter: ((function(ol.layer.Layer): boolean)|undefined),
|
||||||
* layerFilterThis: (Object|undefined),
|
* layerFilterThis: (Object|undefined),
|
||||||
* hitTolerance: (number|undefined)}}
|
* hitTolerance: (number|undefined)}}
|
||||||
*/
|
*/
|
||||||
olx.ForEachFeatureOptions;
|
olx.FeatureAtPixelOptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layer filter function. Only layers which are visible and for which this function returns
|
* Layer filter function. The filter function will receive one argument, the
|
||||||
* `true` will be tested for features. By default, all visible layers will
|
* {@link ol.layer.Layer layer-candidate} and it should return a boolean value.
|
||||||
* be tested.
|
* 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)}
|
* @type {((function(ol.layer.Layer): boolean)|undefined)}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
olx.ForEachFeatureOptions.prototype.layerFilter;
|
olx.FeatureAtPixelOptions.prototype.layerFilter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value to use as `this` when executing `layerFilter`.
|
* Value to use as `this` when executing `layerFilter`.
|
||||||
* @type {Object}
|
* @type {Object|undefined}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
olx.ForEachFeatureOptions.prototype.layerFilterThis;
|
olx.FeatureAtPixelOptions.prototype.layerFilterThis;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of a radius in whichs area around the given coordinate features are
|
* Hit-detection tolerance. Pixels inside the radius around the given position
|
||||||
* called.
|
* will be checked for features. This only works for the canvas renderer and
|
||||||
* @type {number}
|
* not for WebGL.
|
||||||
* @api stable
|
* @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
|
* unmanaged layers. To stop detection, callback functions can return a
|
||||||
* truthy value.
|
* truthy value.
|
||||||
* @param {S=} opt_this Value to use as this when executing callback.
|
* @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
|
* @return {T|undefined} Callback result, i.e. the return value of last
|
||||||
* callback execution, or the first truthy callback return value.
|
* callback execution, or the first truthy callback return value.
|
||||||
* @template S,T
|
* @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
|
* Detect if features intersect a pixel on the viewport. Layers included in the
|
||||||
* detection can be configured through `opt_layerFilter`.
|
* detection can be configured through `opt_layerFilter`.
|
||||||
* @param {ol.Pixel} pixel Pixel.
|
* @param {ol.Pixel} pixel Pixel.
|
||||||
* @param {(function(this: U, ol.layer.Layer): boolean)=} opt_layerFilter Layer
|
* @param {olx.FeatureAtPixelOptions=} opt_options Optional options.
|
||||||
* 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`.
|
|
||||||
* @return {boolean} Is there a feature at the given pixel?
|
* @return {boolean} Is there a feature at the given pixel?
|
||||||
* @template U
|
* @template U
|
||||||
* @api
|
* @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_) {
|
if (!this.frameState_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var coordinate = this.getCoordinateFromPixel(pixel);
|
var coordinate = this.getCoordinateFromPixel(pixel);
|
||||||
var layerFilter = opt_layerFilter !== undefined ?
|
var layerFilter = opt_options.layerFilter !== undefined ?
|
||||||
opt_layerFilter : ol.functions.TRUE;
|
opt_options.layerFilter : ol.functions.TRUE;
|
||||||
var thisArg = opt_this !== undefined ? opt_this : null;
|
var thisArg = opt_options.layerFilterThis !== undefined ? opt_options.layerFilterThis : null;
|
||||||
return this.renderer_.hasFeatureAtCoordinate(
|
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 {ol.Coordinate} coordinate Coordinate.
|
||||||
* @param {olx.FrameState} frameState FrameState.
|
* @param {olx.FrameState} frameState FrameState.
|
||||||
|
* @param {number} hitTolerance HitTolerance.
|
||||||
* @param {function(this: U, ol.layer.Layer): boolean} layerFilter Layer filter
|
* @param {function(this: U, ol.layer.Layer): boolean} layerFilter Layer filter
|
||||||
* function, only layers which are visible and for which this function
|
* function, only layers which are visible and for which this function
|
||||||
* returns `true` will be tested for features. By default, all visible
|
* 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?
|
* @return {boolean} Is there a feature at the given coordinate?
|
||||||
* @template U
|
* @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(
|
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;
|
return hasFeature !== undefined;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @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;
|
var hasFeature = false;
|
||||||
|
|
||||||
if (this.getGL().isContextLost()) {
|
if (this.getGL().isContextLost()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user