Merge pull request #1298 from ahocevar/gfi-callback

The source determines who can do GetFeatureInfo
This commit is contained in:
ahocevar
2013-11-20 07:11:51 -08:00
2 changed files with 7 additions and 5 deletions

View File

@@ -48,17 +48,21 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
* successful queries. The passed arguments are the resulting feature
* information and the layer.
* @param {function()=} opt_error Callback for unsuccessful queries.
* @return {boolean} Whether getFeatureInfoForPixel was called on the source.
*/
ol.renderer.Layer.prototype.getFeatureInfoForPixel =
function(pixel, success, opt_error) {
var layer = this.getLayer();
var source = layer.getSource();
var haveGetFeatureInfo = false;
if (goog.isFunction(source.getFeatureInfoForPixel)) {
var callback = function(layerFeatureInfo) {
success(layerFeatureInfo, layer);
};
source.getFeatureInfoForPixel(pixel, this.getMap(), callback, opt_error);
haveGetFeatureInfo = true;
}
return haveGetFeatureInfo;
};