allow hydrating clustered features
This commit is contained in:
@@ -38,6 +38,8 @@ import {getUid} from '../util.js';
|
||||
* return feature.getGeometry();
|
||||
* }
|
||||
* ```
|
||||
* @property {function(Feature, Array<Feature>):any} [hydrate] Function called after creating
|
||||
* cluster feature
|
||||
* See {@link module:ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster
|
||||
* calculation point for polygons.
|
||||
* @property {VectorSource} [source] Source.
|
||||
@@ -108,6 +110,12 @@ class Cluster extends VectorSource {
|
||||
return geometry;
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {function(Feature, Array<Feature>):any}
|
||||
* @protected
|
||||
*/
|
||||
this.hydrate = options.hydrate;
|
||||
|
||||
/**
|
||||
* @type {VectorSource}
|
||||
* @protected
|
||||
@@ -295,6 +303,9 @@ class Cluster extends VectorSource {
|
||||
centroid[1] * (1 - ratio) + searchCenter[1] * ratio,
|
||||
]);
|
||||
const cluster = new Feature(geometry);
|
||||
if (this.hydrate) {
|
||||
this.hydrate(cluster, features);
|
||||
}
|
||||
cluster.set('features', features, true);
|
||||
return cluster;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user