Pass layer to forEachFeatureAtPixel callback

This commit is contained in:
Tom Payne
2013-12-02 16:45:50 +01:00
parent f1a9f76841
commit e9267e401c
4 changed files with 8 additions and 4 deletions

View File

@@ -457,7 +457,8 @@ ol.Map.prototype.disposeInternal = function() {
/** /**
* @param {ol.Pixel} pixel Pixel. * @param {ol.Pixel} pixel Pixel.
* @param {function(this: S, ol.Feature): T} callback Feature callback. * @param {function(this: S, ol.Feature, ol.layer.Layer): T} callback Feature
* callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_obj Scope.
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T * @template S,T

View File

@@ -92,6 +92,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
goog.asserts.assert(!ol.extent.isEmpty(this.renderedExtent_)); goog.asserts.assert(!ol.extent.isEmpty(this.renderedExtent_));
goog.asserts.assert(!isNaN(this.renderedResolution_)); goog.asserts.assert(!isNaN(this.renderedResolution_));
var coordinate = this.getMap().getCoordinateFromPixel(pixel); var coordinate = this.getMap().getCoordinateFromPixel(pixel);
var layer = this.getLayer();
var renderGeometryFunction = this.getRenderGeometryFunction_(); var renderGeometryFunction = this.getRenderGeometryFunction_();
goog.asserts.assert(goog.isFunction(renderGeometryFunction)); goog.asserts.assert(goog.isFunction(renderGeometryFunction));
return this.replayGroup_.forEachGeometryAtCoordinate(this.renderedExtent_, return this.replayGroup_.forEachGeometryAtCoordinate(this.renderedExtent_,
@@ -103,7 +104,7 @@ ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtPixel =
function(geometry, data) { function(geometry, data) {
var feature = /** @type {ol.Feature} */ (data); var feature = /** @type {ol.Feature} */ (data);
goog.asserts.assert(goog.isDef(feature)); goog.asserts.assert(goog.isDef(feature));
return callback.call(opt_obj, feature); return callback.call(opt_obj, feature, layer);
}); });
} }
}; };

View File

@@ -44,7 +44,8 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
/** /**
* @param {ol.Pixel} pixel Pixel. * @param {ol.Pixel} pixel Pixel.
* @param {function(this: S, ol.Feature): T} callback Feature callback. * @param {function(this: S, ol.Feature, ol.layer.Layer): T} callback Feature
* callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_obj Scope.
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T * @template S,T

View File

@@ -80,7 +80,8 @@ ol.renderer.Map.prototype.disposeInternal = function() {
/** /**
* @param {ol.Pixel} pixel Pixel. * @param {ol.Pixel} pixel Pixel.
* @param {function(this: S, ol.Feature): T} callback Feature callback. * @param {function(this: S, ol.Feature, ol.layer.Layer): T} callback Feature
* callback.
* @param {S=} opt_obj Scope. * @param {S=} opt_obj Scope.
* @return {T|undefined} Callback result. * @return {T|undefined} Callback result.
* @template S,T * @template S,T