Continue passing null instead of unmanaged layer to forEachFeatureAtCoordinate

This commit is contained in:
Andreas Hocevar
2016-02-17 08:16:21 +01:00
parent 9f0fefd42d
commit 5bc00d8535
3 changed files with 8 additions and 7 deletions

View File

@@ -604,8 +604,9 @@ ol.Map.prototype.disposeInternal = function() {
* called with two arguments. The first argument is one
* {@link ol.Feature feature} or
* {@link ol.render.Feature render feature} at the pixel, the second is
* the {@link ol.layer.Layer layer} of the feature. To stop detection,
* callback functions can return a truthy value.
* the {@link ol.layer.Layer layer} of the feature and will be null for
* 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 {(function(this: U, ol.layer.Layer): boolean)=} opt_layerFilter Layer
* filter function. The filter function will receive one argument, the

View File

@@ -139,9 +139,9 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, fram
function forEachFeatureAtCoordinate(feature, layer) {
goog.asserts.assert(feature !== undefined, 'received a feature');
var key = goog.getUid(feature).toString();
if (!(key in frameState.skippedFeatureUids &&
!frameState.layerStates[goog.getUid(layer)].managed)) {
return callback.call(thisArg, feature, layer);
var managed = frameState.layerStates[goog.getUid(layer)].managed;
if (!(key in frameState.skippedFeatureUids && !managed)) {
return callback.call(thisArg, feature, managed ? layer : null);
}
}

View File

@@ -55,13 +55,13 @@ describe('ol.renderer.canvas.Map', function() {
expect(cb.firstCall.args[1]).to.be(layer);
});
it('calls callback for unmanaged layers', function() {
it('calls callback with null for unmanaged layers', function() {
layer.setMap(map);
map.renderSync();
var cb = sinon.spy();
map.forEachFeatureAtPixel(map.getPixelFromCoordinate([0, 0]), cb);
expect(cb).to.be.called();
expect(cb.firstCall.args[1]).to.be(layer);
expect(cb.firstCall.args[1]).to.be(null);
});
it('calls callback with main layer when skipped feature on unmanaged layer', function() {