2012-07-10 18:54:39 -07:00
|
|
|
Leaflet.markercluster
|
|
|
|
=====================
|
|
|
|
|
2012-07-11 14:13:46 +12:00
|
|
|
Provides Marker Clustering functionality for Leaflet
|
|
|
|
|
|
|
|
##Using the plugin
|
|
|
|
See the included example for usage.
|
|
|
|
|
|
|
|
Create a new MarkerClusterGroup, add your markers to it, then add it to the map
|
2012-07-12 00:15:35 +03:00
|
|
|
|
|
|
|
```javascript
|
2012-07-11 14:13:46 +12:00
|
|
|
var markers = new L.MarkerClusterGroup();
|
|
|
|
markers.addLayer(new L.Marker(getRandomLatLng(map)));
|
|
|
|
map.addLayer(markers);
|
2012-07-12 00:15:35 +03:00
|
|
|
```
|
2012-07-11 14:13:46 +12:00
|
|
|
|
|
|
|
For a more complete example see example/marker-clustering.html
|
|
|
|
|
|
|
|
###Customising the Clustered Marker
|
|
|
|
As an option to MarkerClusterGroup you can provide your own function for creating the Icon for the clustered markers.
|
|
|
|
The default implementation changes color at bounds of 10 and 100, but more advanced uses may require customising this.
|
|
|
|
|
2012-07-12 00:15:35 +03:00
|
|
|
```javascript
|
2012-07-11 14:13:46 +12:00
|
|
|
var markers = new L.MarkerClusterGroup({ options: {
|
|
|
|
iconCreateFunction: function(childCount) {
|
|
|
|
return new L.DivIcon({ html: '<b>' + childCount + '</b>' });
|
|
|
|
}
|
|
|
|
}});
|
2012-07-12 00:15:35 +03:00
|
|
|
```
|