Interface for GetFeatureInfo
When a source implements this interface, the layer renderer can access the source to get feature info.
This commit is contained in:
@@ -73,6 +73,26 @@ ol.renderer.Layer = function(mapRenderer, layer) {
|
||||
goog.inherits(ol.renderer.Layer, goog.Disposable);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
|
||||
* @param {function(string, ol.layer.Layer)} success Callback for
|
||||
* successful queries. The passed arguments are the resulting feature
|
||||
* information and the layer.
|
||||
* @param {function()=} opt_error Callback for unsuccessful queries.
|
||||
*/
|
||||
ol.renderer.Layer.prototype.getFeatureInfoForPixel =
|
||||
function(pixel, success, opt_error) {
|
||||
var layer = this.getLayer();
|
||||
var source = layer.getSource();
|
||||
if (goog.isFunction(source.getFeatureInfoForPixel)) {
|
||||
var callback = function(layerFeatureInfo) {
|
||||
success(layerFeatureInfo, layer);
|
||||
};
|
||||
source.getFeatureInfoForPixel(pixel, this.getMap(), callback, opt_error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @return {ol.layer.Layer} Layer.
|
||||
|
||||
Reference in New Issue
Block a user