Shorter name for the option to create a custom cluster

This commit is contained in:
Tim Schaub
2021-07-15 21:35:59 -06:00
parent a617ef3caf
commit 1b9329ea91
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -40,7 +40,7 @@ import {getUid} from '../util.js';
* ``` * ```
* See {@link module:ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster * See {@link module:ol/geom/Polygon~Polygon#getInteriorPoint} for a way to get a cluster
* calculation point for polygons. * calculation point for polygons.
* @property {function(Point, Array<Feature>):Feature} [createClusterFeature] * @property {function(Point, Array<Feature>):Feature} [createCluster]
* Function that takes the cluster's center {@link module:ol/geom/Point} and an array * Function that takes the cluster's center {@link module:ol/geom/Point} and an array
* of {@link module:ol/Feature} included in this cluster. Must return a * of {@link module:ol/Feature} included in this cluster. Must return a
* {@link module:ol/Feature} that will be used to render. Default implementation is: * {@link module:ol/Feature} that will be used to render. Default implementation is:
@@ -122,9 +122,9 @@ class Cluster extends VectorSource {
/** /**
* @type {function(Point, Array<Feature>):Feature} * @type {function(Point, Array<Feature>):Feature}
* @protected * @private
*/ */
this.createClusterFeature = options.createClusterFeature; this.createCustomCluster_ = options.createCluster;
/** /**
* @type {VectorSource} * @type {VectorSource}
@@ -312,8 +312,8 @@ class Cluster extends VectorSource {
centroid[0] * (1 - ratio) + searchCenter[0] * ratio, centroid[0] * (1 - ratio) + searchCenter[0] * ratio,
centroid[1] * (1 - ratio) + searchCenter[1] * ratio, centroid[1] * (1 - ratio) + searchCenter[1] * ratio,
]); ]);
if (this.createClusterFeature) { if (this.createCustomCluster_) {
return this.createClusterFeature(geometry, features); return this.createCustomCluster_(geometry, features);
} else { } else {
return new Feature({ return new Feature({
geometry, geometry,
+1 -1
View File
@@ -84,7 +84,7 @@ describe('ol.source.Cluster', function () {
source: new VectorSource({ source: new VectorSource({
features: [feature1, feature2], features: [feature1, feature2],
}), }),
createClusterFeature: function (clusterPoint, features) { createCluster: function (clusterPoint, features) {
let sum = 0; let sum = 0;
for (const ft of features) { for (const ft of features) {
sum += ft.get('value'); sum += ft.get('value');