[#362,view/map][s]: disable auto-turn on of map clustering above a certain number of points - fixes #362.

This commit is contained in:
Rufus Pollock
2013-06-22 18:14:50 +01:00
parent 323f5febdd
commit 35a5f32163
3 changed files with 36 additions and 10 deletions

View File

@@ -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});
}