Add ol.source.Cluster#setDistance function

This commit is contained in:
Frederic Junod
2016-08-22 13:36:44 +02:00
parent f0ca265ad1
commit f164ad7598
4 changed files with 38 additions and 3 deletions

View File

@@ -69,7 +69,7 @@ ol.source.Cluster = function(options) {
this.source_ = options.source;
this.source_.on(ol.events.EventType.CHANGE,
ol.source.Cluster.prototype.onSourceChange_, this);
ol.source.Cluster.prototype.refresh_, this);
};
ol.inherits(ol.source.Cluster, ol.source.Vector);
@@ -99,11 +99,22 @@ ol.source.Cluster.prototype.loadFeatures = function(extent, resolution,
};
/**
* Set the distance in pixels between clusters.
* @param {number} distance The distance in pixels.
* @api
*/
ol.source.Cluster.prototype.setDistance = function(distance) {
this.distance_ = distance;
this.refresh_();
};
/**
* handle the source changing
* @private
*/
ol.source.Cluster.prototype.onSourceChange_ = function() {
ol.source.Cluster.prototype.refresh_ = function() {
this.clear();
this.cluster_();
this.addFeatures(this.features_);