rename to createClusterFeature
This commit is contained in:
@@ -75,7 +75,7 @@ describe('ol.source.Cluster', function () {
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
expect(source.getFeatures()[0].get('features').length).to.be(2);
|
||||
});
|
||||
it('hydrates cluster feature with additional fields', function () {
|
||||
it('custom cluster feature with additional fields', function () {
|
||||
const feature1 = new Feature(new Point([0, 0]));
|
||||
const feature2 = new Feature(new Point([0, 0]));
|
||||
feature1.set('value', 1);
|
||||
@@ -84,14 +84,41 @@ describe('ol.source.Cluster', function () {
|
||||
source: new VectorSource({
|
||||
features: [feature1, feature2],
|
||||
}),
|
||||
hydrate: function (clusterFeature, features) {
|
||||
clusterFeature.set('sum', 3);
|
||||
createClusterFeature: function (clusterPoint, features) {
|
||||
let sum = 0;
|
||||
for (const ft of features) {
|
||||
sum += ft.get('value');
|
||||
}
|
||||
return new Feature({
|
||||
geometry: clusterPoint,
|
||||
sum: sum,
|
||||
});
|
||||
},
|
||||
});
|
||||
source.loadFeatures(extent, 1, projection);
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
expect(source.getFeatures()[0].get('sum')).to.be(3);
|
||||
});
|
||||
it('reacts setCreateClusterFeature', function () {
|
||||
const feature1 = new Feature(new Point([0, 0]));
|
||||
const feature2 = new Feature(new Point([0, 0]));
|
||||
const source = new Cluster({
|
||||
source: new VectorSource({
|
||||
features: [feature1, feature2],
|
||||
}),
|
||||
});
|
||||
source.loadFeatures(extent, 1, projection);
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
expect(source.getFeatures()[0].get('sum')).to.be(undefined);
|
||||
source.setCreateClusterFeature(function (clusterPoint, features) {
|
||||
return new Feature({
|
||||
geometry: clusterPoint,
|
||||
sum: features.length,
|
||||
});
|
||||
});
|
||||
expect(source.getFeatures().length).to.be(1);
|
||||
expect(source.getFeatures()[0].get('sum')).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setDistance', function () {
|
||||
|
||||
Reference in New Issue
Block a user