Manually draw a cluster using markerclusterer for v3 maps

Hey, I'm using the popular markerclusterer plugin for Google maps, which can be found at http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js

I am wondering what function I can use to manually add a cluster token, since I would like when I zoom out to group token servers before sending a huge json load to the wire.

What function is called to add a cluster cluster?

Any help is much appreciated

+3
source share
3 answers

- - MarkerClusterer, , , , :

MarkerClusterer.prototype.AddCluster = function(clat, clng, csize)
{
  var clusterlocation = new google.maps.LatLng(clat, clng)
  var CI = new ClusterIcon(new Cluster(this), this.getStyles, this.getGridSize());
  var index = 0;
  var dv = csize;
  while (dv !== 0) {
    dv = parseInt(dv / 10, 10);
    index++;
  }
  var style = this.styles_[index-1];
  CI.setCenter(clusterlocation);
  $.extend(CI, {sums_ : {text : csize, index: index}, url_ : style['url'], width_ : style['width'], height_ : style['height']});
  CI.setMap(this.map_);
  CI.show();
  CI.triggerClusterClick = function()
  {this.map_.setCenter(clusterlocation);
   this.map_.setZoom(this.map_.getZoom()+1); }
}
+2

@Jakob API Google Maps V3. , - .

MarkerClusterer.prototype.A

    ddCluster = function(clat, clng, csize)
    {
        this.setZoomOnClick(false);
        if (typeof this.aAddClusterIcons == "undefined"){
            this.aAddClusterIcons = [];
        }

        this.activeMap_ = this.getMap();
        var clusterlocation = new google.maps.LatLng(clat, clng)
        var CI = new ClusterIcon(new Cluster(this), this.getStyles, this.getGridSize());
        var index = 0;
        var dv = csize;
        while (dv !== 0) {
            dv = parseInt(dv / 10, 10);
            index++;
        }
        var style = this.styles_[index-1];
        $.extend(CI, {sums_ : {text : csize, index: index}, url_ : style['url'], width_ : style['width'], height_ : style['height'], anchorIcon_: [clat, clng]});
        CI.setCenter(clusterlocation);
        CI.setMap(this.activeMap_);
        CI.show();

        this.aAddClusterIcons.push(CI);
    }
    MarkerClusterer.prototype.RemoveClusters = function(clat, clng, csize)
    {
        if (typeof this.aAddClusterIcons == "undefined"){
            this.aAddClusterIcons = [];
        }

        $.each(this.aAddClusterIcons, function(iIndex, oObj){
            oObj.onRemove();
        });
        this.aAddClusterIcons = [];
    }

+1

If I get this right, you can use the zoom_changed () event of the google map object and, i.e. when map.getZoom()==16to send your json request using a maxNumberOfFetchedPlaces so that your server can return a limited number of results. Since the initialization of markerClusterer is similar to var markerClusterer = new MarkerClusterer(map, fetchedPlacesArray);you will not have a problem.

Greetings

0
source

Source: https://habr.com/ru/post/1788063/


All Articles