angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

Cluster minimumClusterSize can't be update dynamically

Open tianxu0836 opened this issue 10 years ago • 4 comments

I have two clusters and I only want always two clusters on the map. so I want to make sure minimumClusterSize get increased after a new marker add to it. The minimumClusterSize should always equals the total markers in the cluster.

when I click on the map, I will add a new marker to the first cluster(the cluster starts with 5 markers) I realized that after I add a new marker, minimumClusterSize can't be updated. when you keep adding markers at some point, you will see more than two clusters. However, I only wants two clusters.

Here is the plnkr with the issue: http://plnkr.co/edit/TlkZ18IMbWKxI8pdgwko?p=preview

btw, it seems MarkerClusterer methods can't be accessed in the angular google maps? How do you call "setMinimumClusterSize()"?

tianxu0836 avatar Nov 12 '15 20:11 tianxu0836

dupe #1614 if you want it more angularly you might need to make a PR. Otherwise try typeOptions http://angular-ui.github.io/angular-google-maps/#!/api/markers

nmccready avatar Nov 12 '15 20:11 nmccready

I am using typeOptions it doesn't work for this case

tianxu0836 avatar Nov 12 '15 21:11 tianxu0836

Your gonna need to dive into the source and make a PR, I do not have time to work on this.

nmccready avatar Nov 13 '15 02:11 nmccready

We can update it dynamically by keeping a control on uiGmapMarkers directive and accessing that control in controller like this

      'zoom_changed': function(map){
        if (map.getZoom() >= 12) {
          $timeout(function(){
            vm.markerControl.getManager().clusterer.gridSize_ = 1;
            vm.markerControl.getManager().clusterer.minClusterSize_ = 2;
          });
        } else {
          $timeout(function(){
            vm.markerControl.getManager().clusterer.gridSize_ = 50;
            vm.markerControl.getManager().clusterer.minClusterSize_ = 50;
          });
        }
      }
    };

trilok9999 avatar Jan 27 '17 03:01 trilok9999