Implement hasFeatureAtPixel for canvas

This commit is contained in:
tsauerwein
2014-12-19 14:46:54 +01:00
parent d0691ecc4d
commit d62e910239
2 changed files with 28 additions and 0 deletions

View File

@@ -54,6 +54,14 @@ goog.inherits(ol.renderer.Layer, goog.Disposable);
ol.renderer.Layer.prototype.forEachFeatureAtPixel = goog.nullFunction;
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @param {olx.FrameState} frameState Frame state.
* @return {boolean} Is there a feature at the given pixel?
*/
ol.renderer.Layer.prototype.hasFeatureAtPixel = goog.functions.FALSE;
/**
* @protected
* @return {ol.layer.Layer} Layer.

View File

@@ -169,6 +169,26 @@ ol.renderer.Map.prototype.forEachFeatureAtPixel =
};
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @param {olx.FrameState} frameState FrameState.
* @param {function(this: U, ol.layer.Layer): boolean} layerFilter Layer filter
* function, only layers which are visible and for which this function
* returns `true` will be tested for features. By default, all visible
* layers will be tested.
* @param {U} thisArg Value to use as `this` when executing `layerFilter`.
* @return {boolean} Is there a feature at the given pixel?
* @template U
*/
ol.renderer.Map.prototype.hasFeatureAtPixel =
function(coordinate, frameState, layerFilter, thisArg) {
var hasFeature = this.forEachFeatureAtPixel(
coordinate, frameState, goog.functions.TRUE, this, layerFilter, thisArg);
return goog.isDef(hasFeature) ? hasFeature : false;
};
/**
* @param {ol.layer.Layer} layer Layer.
* @protected