New Layer#getFeatures method with fast hit detection for VectorLayer

This commit is contained in:
Andreas Hocevar
2019-09-26 19:55:14 +02:00
parent 057cc92716
commit 315695eeb8
13 changed files with 429 additions and 31 deletions

View File

@@ -135,6 +135,24 @@ class BaseVectorLayer extends Layer {
return this.declutter_;
}
/**
* Get the topmost feature that intersects the given pixel on the viewport. Returns a promise
* that resolves with an array of features. The array will either contain the topmost feature
* when a hit was detected, or it will be empty.
*
* The hit detection algorithm used for this method is optimized for performance, but is less
* accurate than the one used in {@link import("../PluggableMap.js").default#getFeaturesAtPixel}: Text
* is not considered, and icons are only represented by their bounding box instead of the exact
* image.
*
* @param {import("../pixel.js").Pixel} pixel Pixel.
* @return {Promise<Array<import("../Feature").default>>} Promise that resolves with an array of features.
* @api
*/
getFeatures(pixel) {
return super.getFeatures(pixel);
}
/**
* @return {number|undefined} Render buffer.
*/