In order to add region-awareness to your clusters using RegionBound you do not have to change any calls related to the clustering itself.
You just need to add region information when you create your markers.
Your existing Leaflet/Leaflet.markercluster code probably looks something like this:
var map = L.map("mymap"); L.tileLayer(...).addTo(map); var clusterGroup = new L.MarkerClusterGroup(); var marker1 = new L.marker([-37.8, 145]); var marker2 = new L.marker([-33.9, 151]); clusterGroup.addLayer(marker1); clusterGroup.addLayer(marker2); map.addLayer(clusterGroup);
All you need to do to unleash RegionBound is add an extra parameter to the L.marker(...)
calls:
var marker1 = new L.marker([-37.8, 145], {regions: ["Asia-Pac", "Australia", "VIC", "Melbourne"]} ); var marker2 = new L.marker([-33.9, 151], {regions: ["Asia-Pac", "Australia", "NSW", "Sydney"]} );
Couldn't be much easier, could it?
The download has more elaborate examples, showing you how to pass in additional configuration parameters, like the cluster radius, if you wish.
But in essence this is all there is to it!
For testing purposes, the download also has instructions on how to generate thousands of random locations and postal addresses for almost any country in the world.