openlayers/ol3 — pull request #1528 by elemoine (2014-01-14 15:07:23+00:00)
Title: [vector-api] Change forEachFeatureAtPixel signature

With this PR the signature of `forEachFeatureAtPixel` is changed to:

```
/**
* @param {ol.Pixel} pixel Pixel.
* @param {function(this: S, ol.Feature, ol.layer.Layer): T} callback Feature callback.
* @param {S=} opt_scope Scope for feature callback.
* @param {olx.MapForEachFeatureAtPixelOptions=} opt_options Options.
* @return {T|undefined} Callback result.
* @template S,T
*/
```

So instead of

```js
map.forEachFeatureAtPixel(pixel, function(feature, layer) {
...
}, callbackScope, function(layer) {
...
}, layerFunctionScope);
```

the use is now:

```js
map.forEachFeatureAtPixel(pixel, function(feature, layer) {
...
}, callbackScope, {
layerFunction: function(layer) {
},
layerFunctionScope: layerFunctionScope
});
```

The simple case remains identical:

```js
map.forEachFeatureAtPixel(pixel, function(feature, layer) {
...
});
```

(`opt_scope` and `opt_options` are optional arguments.)

This change is in preparation for the addition of a `tolerance` option, as adding a fifth argument does not sound like a very good idea.

@twpayne has suggested to place the `options` argument first. But with that the simple case would then become:

```js
map.forEachFeatureAtPixel(null, pixel, function(feature, layer) {
...
});
```

which I personally don't like too much.

Please review.