function explodeSmallClusters($minNbCluster) { try { //check number format if (intval($minNbCluster) > 0) { $clustersExploded = array(); foreach ($this->clusters as $cluster) { if ($cluster->markers != null && count($cluster->markers) < $minNbCluster) { foreach ($cluster->markers as $markerToAdd) { $clusterToAdd = new Cluster($this); $clusterToAdd->addMarker($markerToAdd); $clustersExploded[] = $clusterToAdd; } } else { $clustersExploded[] = $cluster; } } $this->clusters = $clustersExploded; } } catch (Exception $e) { // TODO: handle exception } }