Openlayer 5 使用坐标点查询最近的图层feature
vector.getClosestFeatureToCoordinate(coordinates);
// 返回指定图层距离该坐标最近的faeture
官方API:
getClosestFeatureToCoordinate(coordinate, opt_filter){module:ol/Feature~Feature} inherited
Get the closest feature to the provided coordinate.
This method is not available when the source is configured with useSpatialIndex
set to false.
Name Type Description
coordinate
module:ol/coordinate~Coordinate Coordinate.
filter
function**
Feature filter function. The filter function will receive one argument, the feature and it should return a boolean value. By default, no filtering is made.
Returns: Closest feature.
API URL:https://openlayers.org/en/latest/apidoc/module-ol_source_Cluster-Cluster.html#getClosestFeatureToCoordinate