Support hitTolerance in forEachLayerAtPixel
This commit is contained in:
@@ -181,6 +181,7 @@ MapRenderer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameSta
|
||||
* @abstract
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/PluggableMap~FrameState} frameState FrameState.
|
||||
* @param {number} hitTolerance Hit tolerance in pixels.
|
||||
* @param {function(this: S, module:ol/layer/Layer, (Uint8ClampedArray|Uint8Array)): T} callback Layer
|
||||
* callback.
|
||||
* @param {S} thisArg Value to use as `this` when executing `callback`.
|
||||
@@ -192,7 +193,7 @@ MapRenderer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameSta
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template S,T,U
|
||||
*/
|
||||
MapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg,
|
||||
MapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, hitTolerance, callback, thisArg,
|
||||
layerFilter, thisArg2) {};
|
||||
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ IntermediateCanvasRenderer.prototype.forEachFeatureAtCoordinate = function(coord
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
IntermediateCanvasRenderer.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, callback, thisArg) {
|
||||
IntermediateCanvasRenderer.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
||||
if (!this.getImage()) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -147,4 +147,5 @@ IntermediateCanvasRenderer.prototype.forEachLayerAtCoordinate = function(coordin
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default IntermediateCanvasRenderer;
|
||||
|
||||
@@ -101,14 +101,15 @@ CanvasLayerRenderer.prototype.dispatchComposeEvent_ = function(type, context, fr
|
||||
/**
|
||||
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
|
||||
* @param {module:ol/PluggableMap~FrameState} frameState FrameState.
|
||||
* @param {number} hitTolerance Hit tolerance in pixels.
|
||||
* @param {function(this: S, module:ol/layer/Layer, (Uint8ClampedArray|Uint8Array)): T} callback Layer
|
||||
* callback.
|
||||
* @param {S} thisArg Value to use as `this` when executing `callback`.
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template S,T,U
|
||||
*/
|
||||
CanvasLayerRenderer.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, callback, thisArg) {
|
||||
const hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, 0, TRUE, this);
|
||||
CanvasLayerRenderer.prototype.forEachLayerAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
||||
const hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, TRUE, this);
|
||||
|
||||
if (hasFeature) {
|
||||
return callback.call(thisArg, this.getLayer(), null);
|
||||
|
||||
@@ -182,7 +182,7 @@ CanvasMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
CanvasMapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg,
|
||||
CanvasMapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, hitTolerance, callback, thisArg,
|
||||
layerFilter, thisArg2) {
|
||||
let result;
|
||||
const viewState = frameState.viewState;
|
||||
@@ -201,7 +201,7 @@ CanvasMapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, ca
|
||||
if (visibleAtResolution(layerState, viewResolution) && layerFilter.call(thisArg2, layer)) {
|
||||
const layerRenderer = /** @type {module:ol/renderer/canvas/Layer} */ (this.getLayerRenderer(layer));
|
||||
result = layerRenderer.forEachLayerAtCoordinate(
|
||||
coordinate, frameState, callback, thisArg);
|
||||
coordinate, frameState, hitTolerance, callback, thisArg);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ WebGLMapRenderer.prototype.hasFeatureAtCoordinate = function(coordinate, frameSt
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLMapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg,
|
||||
WebGLMapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, hitTolerance, callback, thisArg,
|
||||
layerFilter, thisArg2) {
|
||||
if (this.getGL().isContextLost()) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user