Merge pull request #1298 from ahocevar/gfi-callback
The source determines who can do GetFeatureInfo
This commit is contained in:
@@ -48,17 +48,21 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
|
|||||||
* successful queries. The passed arguments are the resulting feature
|
* successful queries. The passed arguments are the resulting feature
|
||||||
* information and the layer.
|
* information and the layer.
|
||||||
* @param {function()=} opt_error Callback for unsuccessful queries.
|
* @param {function()=} opt_error Callback for unsuccessful queries.
|
||||||
|
* @return {boolean} Whether getFeatureInfoForPixel was called on the source.
|
||||||
*/
|
*/
|
||||||
ol.renderer.Layer.prototype.getFeatureInfoForPixel =
|
ol.renderer.Layer.prototype.getFeatureInfoForPixel =
|
||||||
function(pixel, success, opt_error) {
|
function(pixel, success, opt_error) {
|
||||||
var layer = this.getLayer();
|
var layer = this.getLayer();
|
||||||
var source = layer.getSource();
|
var source = layer.getSource();
|
||||||
|
var haveGetFeatureInfo = false;
|
||||||
if (goog.isFunction(source.getFeatureInfoForPixel)) {
|
if (goog.isFunction(source.getFeatureInfoForPixel)) {
|
||||||
var callback = function(layerFeatureInfo) {
|
var callback = function(layerFeatureInfo) {
|
||||||
success(layerFeatureInfo, layer);
|
success(layerFeatureInfo, layer);
|
||||||
};
|
};
|
||||||
source.getFeatureInfoForPixel(pixel, this.getMap(), callback, opt_error);
|
source.getFeatureInfoForPixel(pixel, this.getMap(), callback, opt_error);
|
||||||
|
haveGetFeatureInfo = true;
|
||||||
}
|
}
|
||||||
|
return haveGetFeatureInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -122,13 +122,11 @@ ol.renderer.Map.prototype.getFeatureInfoForPixel =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var layer, layerRenderer;
|
var layerRenderer;
|
||||||
for (var i = 0; i < numLayers; ++i) {
|
for (var i = 0; i < numLayers; ++i) {
|
||||||
layer = layers[i];
|
layerRenderer = this.getLayerRenderer(layers[i]);
|
||||||
layerRenderer = this.getLayerRenderer(layer);
|
if (layerRenderer.getFeatureInfoForPixel(pixel, callback, opt_error)) {
|
||||||
if (goog.isFunction(layerRenderer.getFeatureInfoForPixel)) {
|
|
||||||
++callbackCount;
|
++callbackCount;
|
||||||
layerRenderer.getFeatureInfoForPixel(pixel, callback, opt_error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user