Book Image

Leaflet.js Essentials

Book Image

Leaflet.js Essentials

Overview of this book

Table of Contents (13 chapters)
Leaflet.js Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...