A custom BlueMap web addon that groups nearby markers into clusters, displaying a count badge. Improves performance on maps with many POI markers by reducing DOM elements and culling off-screen markers.
- Marker Clustering - Markers that overlap on screen get grouped into a single badge showing the count
- Click to Expand - Click a cluster badge to reveal the individual markers
- Auto Re-Collapse - Expanded clusters automatically re-collapse when the mouse moves away
- Off-Screen Culling - Markers far outside the viewport are hidden from rendering entirely
- Throttled Updates - Clustering recalculates on a configurable interval (default 500ms) instead of every frame
- Live Badge Tracking - Cluster badges follow their markers in real-time via requestAnimationFrame
- Hover Tooltip - Hovering a cluster shows the names of all markers inside it
- Configurable - Adjust cluster radius, update speed, culling padding, and more
-
Copy
marker-cluster.jsandmarker-cluster.cssinto your BlueMap webroot folder:./bluemap/web/marker-cluster.js ./bluemap/web/marker-cluster.css -
Edit your
webapp.conf(usually at./plugins/BlueMap/webapp.conf) and add both files:scripts: [ "marker-cluster.js" ] styles: [ "marker-cluster.css" ]
-
Reload BlueMap:
/bluemap reload light -
Open map in a browser. Markers that are close together will now cluster.
Open marker-cluster.js and edit the CONFIG object at the top:
| Option | Default | Description |
|---|---|---|
clusterRadius |
80 |
Pixel distance within which markers get grouped |
minClusterSize |
3 |
Minimum markers needed to form a cluster |
maxClusterSize |
8 |
Maximum markers allowed in a single cluster (forces large groups to break up) |
groupingInterval |
500 |
Milliseconds between clustering recalculations |
cullOffScreen |
true |
Hide markers outside the viewport for performance |
cullPadding |
200 |
Extra pixels beyond viewport edge before culling |
If your map is still laggy after installing this script, try these additional tweaks:
- Increase
clusterRadius(pixels) to group more aggressively - Increase
groupingInterval(ms) if CPU is still high (slightly less responsive) - Enable
cullOffScreen(on by default) - this alone helps significantly with 100+ markers - Reduce marker icon sizes in your marker configs - smaller images = faster rendering
- Use fewer marker sets - each set adds overhead to BlueMap's internal rendering loop
- Every
groupingIntervalms, the script scans all visible POI/HTML marker DOM elements - It parses their
transform: translate(x, y)to get screen positions - Off-screen markers get
visibility: hidden(still in DOM but skip paint/composite) - Remaining markers are grouped using a greedy nearest-neighbor algorithm
- Groups meeting the
minClusterSizethreshold get hidden (display: nonevia CSS class) and replaced with a cluster badge at the centroid - Badge positions update every frame via requestAnimationFrame to stay glued to moving markers
- Clicking a badge removes it and restores the individual markers
- When the mouse moves away from an expanded group (beyond
clusterRadius), it automatically re-collapses
Open browser console and:
- Check for
[MarkerCluster] Initializedmessage on load - Call
BlueMapClusterDestroy()to disable clustering and restore all markers - Access
BlueMapClusterConfigto view or modify config at runtime
MIT - Free to use and modify.