diff --git a/src/ol/renderer/layerrenderer.js b/src/ol/renderer/layerrenderer.js index 3c87277977..0eff0ddd05 100644 --- a/src/ol/renderer/layerrenderer.js +++ b/src/ol/renderer/layerrenderer.js @@ -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. diff --git a/src/ol/source/featureinfosource.js b/src/ol/source/featureinfosource.js new file mode 100644 index 0000000000..6d061866c0 --- /dev/null +++ b/src/ol/source/featureinfosource.js @@ -0,0 +1,18 @@ +goog.provide('ol.source.FeatureInfoSource'); + + + +/** + * @interface + */ +ol.source.FeatureInfoSource = function() {}; + + +/** + * @param {ol.Pixel} pixel Pixel. + * @param {ol.Map} map The map that the pixel belongs to. + * @param {function(string)} success Callback with feature info. + * @param {function()=} opt_error Optional error callback. + */ +ol.source.FeatureInfoSource.prototype.getFeatureInfoForPixel = + goog.abstractMethod;