remove setter/getter
This commit is contained in:
@@ -41,8 +41,8 @@ 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} [createClusterFeature]
|
||||||
* Function that takes cluster's ceter {@link module:ol/geom/Point} and 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
|
* 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:
|
||||||
* ```js
|
* ```js
|
||||||
* function(point, features) {
|
* function(point, features) {
|
||||||
@@ -198,28 +198,6 @@ class Cluster extends VectorSource {
|
|||||||
this.updateDistance(this.distance, minDistance);
|
this.updateDistance(this.distance, minDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Current function used to create cluster features
|
|
||||||
* @return {function(Point, Array<Feature>):Feature | undefined} cluster creation function
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
getCreateClusterFeature() {
|
|
||||||
return this.createClusterFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set function used to create cluster features
|
|
||||||
* @param {function(Point, Array<Feature>):Feature | undefined} createClusterFeature creation function
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
setCreateClusterFeature(createClusterFeature) {
|
|
||||||
const changed = this.createClusterFeature != createClusterFeature;
|
|
||||||
this.createClusterFeature = createClusterFeature;
|
|
||||||
if (changed) {
|
|
||||||
this.refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The configured minimum distance between clusters.
|
* The configured minimum distance between clusters.
|
||||||
* @return {number} The minimum distance in pixels.
|
* @return {number} The minimum distance in pixels.
|
||||||
|
|||||||
@@ -99,26 +99,6 @@ describe('ol.source.Cluster', function () {
|
|||||||
expect(source.getFeatures().length).to.be(1);
|
expect(source.getFeatures().length).to.be(1);
|
||||||
expect(source.getFeatures()[0].get('sum')).to.be(3);
|
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 () {
|
describe('#setDistance', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user