[#362,view/map][s]: disable auto-turn on of map clustering above a certain number of points - fixes #362.
This commit is contained in:
@@ -102,3 +102,30 @@ view.featureparse = function (e) {
|
||||
};
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### Turning on clustering
|
||||
|
||||
You can turn on clustering of markers by setting the cluster option:
|
||||
|
||||
var map = new recline.View.Map({
|
||||
model: dataset
|
||||
state: {
|
||||
cluster: true;
|
||||
}
|
||||
});
|
||||
|
||||
You could also enable marker clustering only if you have more than a
|
||||
certain number of markers. Here's an example:
|
||||
|
||||
// var map is recline.View.Map instance
|
||||
// marker cluster threshold
|
||||
var threshold = 65;
|
||||
|
||||
// enable clustering if there is a large number of markers
|
||||
var countAfter = 0;
|
||||
map.features.eachLayer(function(){countAfter++;});
|
||||
if (countAfter > threshold) {
|
||||
// note the map will auto-redraw when you change state!
|
||||
map.state.set({cluster: true});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user