diff --git a/src/ol/render/canvas/replaygroup.js b/src/ol/render/canvas/replaygroup.js index 7f349dac43..26e6dd8291 100644 --- a/src/ol/render/canvas/replaygroup.js +++ b/src/ol/render/canvas/replaygroup.js @@ -88,6 +88,7 @@ ol.render.canvas.ReplayGroup.prototype.finish = function() { * @param {ol.Coordinate} coordinate Coordinate. * @param {number} resolution Resolution. * @param {number} rotation Rotation. + * @param {number} hitTolerance hit tolerance. * @param {Object.} skippedFeaturesHash Ids of features * to skip. * @param {function((ol.Feature|ol.render.Feature)): T} callback Feature @@ -96,9 +97,8 @@ ol.render.canvas.ReplayGroup.prototype.finish = function() { * @template T */ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function( - coordinate, resolution, rotation, skippedFeaturesHash, callback) { + coordinate, resolution, rotation, hitTolerance, skippedFeaturesHash, callback) { - var hitTolerance = 10; var contextSize = hitTolerance * 2 + 1; var transform = ol.transform.compose(ol.transform.create(), diff --git a/src/ol/renderer/canvas/vectorlayer.js b/src/ol/renderer/canvas/vectorlayer.js index cd375e0f94..449df71c7a 100644 --- a/src/ol/renderer/canvas/vectorlayer.js +++ b/src/ol/renderer/canvas/vectorlayer.js @@ -177,7 +177,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame = function(frameState, lay /** * @inheritDoc */ -ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg) { +ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { if (!this.replayGroup_) { return undefined; } else { @@ -187,7 +187,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = function(c /** @type {Object.} */ var features = {}; return this.replayGroup_.forEachFeatureAtCoordinate(coordinate, resolution, - rotation, {}, + rotation, hitTolerance, {}, /** * @param {ol.Feature|ol.render.Feature} feature Feature. * @return {?} Callback result. diff --git a/src/ol/renderer/canvas/vectortilelayer.js b/src/ol/renderer/canvas/vectortilelayer.js index ee4e14a14c..082d19d62b 100644 --- a/src/ol/renderer/canvas/vectortilelayer.js +++ b/src/ol/renderer/canvas/vectortilelayer.js @@ -176,7 +176,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.drawTileImage = function( /** * @inheritDoc */ -ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg) { +ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { var resolution = frameState.viewState.resolution; var rotation = frameState.viewState.rotation; var layer = this.getLayer(); @@ -212,7 +212,7 @@ ol.renderer.canvas.VectorTileLayer.prototype.forEachFeatureAtCoordinate = functi } replayGroup = tile.getReplayState().replayGroup; found = found || replayGroup.forEachFeatureAtCoordinate( - tileSpaceCoordinate, resolution, rotation, {}, + tileSpaceCoordinate, resolution, rotation, hitTolerance, {}, /** * @param {ol.Feature|ol.render.Feature} feature Feature. * @return {?} Callback result. diff --git a/src/ol/renderer/layer.js b/src/ol/renderer/layer.js index 2e96ea86d3..cab6f36e06 100644 --- a/src/ol/renderer/layer.js +++ b/src/ol/renderer/layer.js @@ -35,6 +35,7 @@ ol.inherits(ol.renderer.Layer, ol.Observable); /** * @param {ol.Coordinate} coordinate Coordinate. * @param {olx.FrameState} frameState Frame state. + * @param {number} hitTolerance hit tolerance. * @param {function(this: S, (ol.Feature|ol.render.Feature), ol.layer.Layer): T} * callback Feature callback. * @param {S} thisArg Value to use as `this` when executing `callback`. diff --git a/src/ol/renderer/map.js b/src/ol/renderer/map.js index e9f0d8bae0..da80986fd2 100644 --- a/src/ol/renderer/map.js +++ b/src/ol/renderer/map.js @@ -100,6 +100,7 @@ ol.renderer.Map.expireIconCache_ = function(map, frameState) { /** * @param {ol.Coordinate} coordinate Coordinate. * @param {olx.FrameState} frameState FrameState. + * @param {number} hitTolerance hit tolerance. * @param {function(this: S, (ol.Feature|ol.render.Feature), * ol.layer.Layer): T} callback Feature callback. * @param {S} thisArg Value to use as `this` when executing `callback`. @@ -111,7 +112,7 @@ ol.renderer.Map.expireIconCache_ = function(map, frameState) { * @return {T|undefined} Callback result. * @template S,T,U */ -ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg, +ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg, layerFilter, thisArg2) { var result; var viewState = frameState.viewState; @@ -155,7 +156,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, fram if (layer.getSource()) { result = layerRenderer.forEachFeatureAtCoordinate( layer.getSource().getWrapX() ? translatedCoordinate : coordinate, - frameState, forEachFeatureAtCoordinate, thisArg); + frameState, hitTolerance, forEachFeatureAtCoordinate, thisArg); } if (result) { return result; diff --git a/src/ol/renderer/webgl/imagelayer.js b/src/ol/renderer/webgl/imagelayer.js index 8df0c036df..9ef477e9a8 100644 --- a/src/ol/renderer/webgl/imagelayer.js +++ b/src/ol/renderer/webgl/imagelayer.js @@ -68,14 +68,14 @@ ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) { /** * @inheritDoc */ -ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg) { +ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { var layer = this.getLayer(); var source = layer.getSource(); var resolution = frameState.viewState.resolution; var rotation = frameState.viewState.rotation; var skippedFeatureUids = frameState.skippedFeatureUids; return source.forEachFeatureAtCoordinate( - coordinate, resolution, rotation, skippedFeatureUids, + coordinate, resolution, rotation, hitTolerance, skippedFeatureUids, /** * @param {ol.Feature|ol.render.Feature} feature Feature. diff --git a/src/ol/renderer/webgl/map.js b/src/ol/renderer/webgl/map.js index 5844610adf..4022046ab4 100644 --- a/src/ol/renderer/webgl/map.js +++ b/src/ol/renderer/webgl/map.js @@ -502,7 +502,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) { /** * @inheritDoc */ -ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg, +ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg, layerFilter, thisArg2) { var result; @@ -522,7 +522,7 @@ ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate layerFilter.call(thisArg2, layer)) { var layerRenderer = this.getLayerRenderer(layer); result = layerRenderer.forEachFeatureAtCoordinate( - coordinate, frameState, callback, thisArg); + coordinate, frameState, hitTolerance, callback, thisArg); if (result) { return result; } diff --git a/src/ol/renderer/webgl/vectorlayer.js b/src/ol/renderer/webgl/vectorlayer.js index d94975f8a6..e0a6b701e0 100644 --- a/src/ol/renderer/webgl/vectorlayer.js +++ b/src/ol/renderer/webgl/vectorlayer.js @@ -106,7 +106,7 @@ ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() { /** * @inheritDoc */ -ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, callback, thisArg) { +ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) { if (!this.replayGroup_ || !this.layerState_) { return undefined; } else { diff --git a/src/ol/source/imagevector.js b/src/ol/source/imagevector.js index 2eac2bccb0..42d54d58b1 100644 --- a/src/ol/source/imagevector.js +++ b/src/ol/source/imagevector.js @@ -155,14 +155,14 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ = function(extent, resol * @inheritDoc */ ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function( - coordinate, resolution, rotation, skippedFeatureUids, callback) { + coordinate, resolution, rotation, hitTolerance, skippedFeatureUids, callback) { if (!this.replayGroup_) { return undefined; } else { /** @type {Object.} */ var features = {}; return this.replayGroup_.forEachFeatureAtCoordinate( - coordinate, resolution, 0, skippedFeatureUids, + coordinate, resolution, 0, hitTolerance, skippedFeatureUids, /** * @param {ol.Feature|ol.render.Feature} feature Feature. * @return {?} Callback result. diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 6fd4cdf57f..2224022bd8 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -94,6 +94,7 @@ ol.source.Source.toAttributionsArray_ = function(attributionLike) { * @param {ol.Coordinate} coordinate Coordinate. * @param {number} resolution Resolution. * @param {number} rotation Rotation. + * @param {number} hitTolerance Hit tolerance. * @param {Object.} skippedFeatureUids Skipped feature uids. * @param {function((ol.Feature|ol.render.Feature)): T} callback Feature * callback. diff --git a/test/spec/ol/renderer/canvas/vectorlayer.test.js b/test/spec/ol/renderer/canvas/vectorlayer.test.js index a6bab3856d..6fd6750cf4 100644 --- a/test/spec/ol/renderer/canvas/vectorlayer.test.js +++ b/test/spec/ol/renderer/canvas/vectorlayer.test.js @@ -79,7 +79,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { var replayGroup = {}; renderer.replayGroup_ = replayGroup; replayGroup.forEachFeatureAtCoordinate = function(coordinate, - resolution, rotation, skippedFeaturesUids, callback) { + resolution, rotation, hitTolerance, skippedFeaturesUids, callback) { var feature = new ol.Feature(); callback(feature); callback(feature); @@ -99,7 +99,7 @@ describe('ol.renderer.canvas.VectorLayer', function() { }; frameState.layerStates[ol.getUid(layer)] = {}; renderer.forEachFeatureAtCoordinate( - coordinate, frameState, spy, undefined); + coordinate, frameState, 0, spy, undefined); expect(spy.callCount).to.be(1); expect(spy.getCall(0).args[1]).to.equal(layer); }); diff --git a/test/spec/ol/renderer/canvas/vectortilelayer.test.js b/test/spec/ol/renderer/canvas/vectortilelayer.test.js index 7979fa3d19..0ff44349d2 100644 --- a/test/spec/ol/renderer/canvas/vectortilelayer.test.js +++ b/test/spec/ol/renderer/canvas/vectortilelayer.test.js @@ -169,7 +169,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { }); renderer = new ol.renderer.canvas.VectorTileLayer(layer); replayGroup.forEachFeatureAtCoordinate = function(coordinate, - resolution, rotation, skippedFeaturesUids, callback) { + resolution, rotation, hitTolerance, skippedFeaturesUids, callback) { var feature = new ol.Feature(); callback(feature); callback(feature); @@ -190,7 +190,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() { frameState.layerStates[ol.getUid(layer)] = {}; renderer.renderedTiles = [new TileClass([0, 0, -1])]; renderer.forEachFeatureAtCoordinate( - coordinate, frameState, spy, undefined); + coordinate, frameState, 0, spy, undefined); expect(spy.callCount).to.be(1); expect(spy.getCall(0).args[1]).to.equal(layer); });