Accessibility - Cluster Marker Titles

This example demonstrates the clusterMarkerTitle option for accessibility. Cluster markers will have a title attribute that screen readers can announce and that appears as a tooltip on hover.

Why is this important?

Configuration:

The clusterMarkerTitle option can be:

let markers = new L.MarkerClusterGroup({
  clusterMarkerTitle: function(cluster) {
    const count = cluster.getChildCount();
    return 'Cluster with ' + count + 
      (count === 1 ? ' marker' : ' markers');
  }
});

// Add markers
for (let i = 0; i < 100; i++) {
  let marker = L.marker(randomLatLng);
  marker.bindPopup('Marker ' + (i + 1));
  markers.addLayer(marker);
}

map.addLayer(markers);

Try it: