Added image data value to 'forEachLayerAtPixel' method callback

The update has been added to the docs for all 'forEachLayerAtPixel' definitions
and currently returns null for non-supporting definitions. ol.Color typeDef
was also updated to support Uint8Arrays & Uint8ClampedArrays as it is the
reference type for the addded argument #5586
This commit is contained in:
Benjamin
2016-08-04 10:08:30 -04:00
parent 7b62f13eb6
commit f73ee14e3c
9 changed files with 51 additions and 20 deletions
+9 -3
View File
@@ -69,7 +69,13 @@ ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate = function(co
/**
* @inheritDoc
* @param {ol.Pixel} pixel Pixel.
* @param {olx.FrameState} frameState FrameState.
* @param {function(this: S, ol.layer.Layer, ol.Color): T} callback Layer
* callback.
* @param {S} thisArg Value to use as `this` when executing `callback`.
* @return {T|undefined} Callback result.
* @template S,T,U
*/
ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
if (!this.getImage()) {
@@ -85,7 +91,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fr
coordinate, frameState, ol.functions.TRUE, this);
if (hasFeature) {
return callback.call(thisArg, this.getLayer());
return callback.call(thisArg, this.getLayer(), null);
} else {
return undefined;
}
@@ -108,7 +114,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, fr
var imageData = this.hitCanvasContext_.getImageData(0, 0, 1, 1).data;
if (imageData[3] > 0) {
return callback.call(thisArg, this.getLayer());
return callback.call(thisArg, this.getLayer(), imageData);
} else {
return undefined;
}
+8 -2
View File
@@ -186,7 +186,13 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(
/**
* @inheritDoc
* @param {ol.Pixel} pixel Pixel.
* @param {olx.FrameState} frameState FrameState.
* @param {function(this: S, ol.layer.Layer, ol.Color): T} callback Layer
* callback.
* @param {S} thisArg Value to use as `this` when executing `callback`.
* @return {T|undefined} Callback result.
* @template S,T,U
*/
ol.renderer.canvas.TileLayer.prototype.forEachLayerAtPixel = function(
pixel, frameState, callback, thisArg) {
@@ -200,7 +206,7 @@ ol.renderer.canvas.TileLayer.prototype.forEachLayerAtPixel = function(
pixel[0], pixel[1], 1, 1).data;
if (imageData[3] > 0) {
return callback.call(thisArg, this.getLayer());
return callback.call(thisArg, this.getLayer(), imageData);
} else {
return undefined;
}