Clustering markers with Leaflet.markercluster
As you create more maps, you will eventually run in to a dataset that is thousands of points. Displaying 10,000 points on a map results in a slow load time, lagging animation on zooming and panning, and makes it hard for the user to select a single marker or to make sense of the data. Clustering allows you to group markers into clusters—single points that expand as the zoom level increases. This way, you can get a sense of the magnitude of data without being visually overwhelmed by the sheer number of points. If you need to see a single point, you can zoom in to the region or point of interest. Leaflet.markercluster
is a fast and powerful cluster implementation that is also visually appealing.
Note
You can download this plugin at https://github.com/Leaflet/Leaflet.markercluster.
Coding your first cluster map
A marker cluster is just another example of a layer in Leaflet. So, creating one should look very familiar to you. You need to perform the following...