quanduyle / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
0 stars 0 forks source link

MarkerClusterer V3 Zoom into the marker #104

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I made a infowindow for clusterer. When user clicks it, the infowindow pops up 
with the information of markers. After that, if user select the specific marker 
from the list, I would like to make zoom until selected marker show 
individually. below is my source code so far.

var mCluster;
ClusterIcon.prototype.triggerClusterClick = function() {
  var markerClusterer = this.cluster_.getMarkerClusterer();

  // Trigger the clusterclick event.
  google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_);

  // added
  infowindow.close();
  mCluster=this.cluster_;
  center = new google.maps.LatLng(mCluster.center_.lat(), mCluster.center_.lng());
  bounds = mCluster.getBounds();

  var bubble='<div align="left" style="height:150; width:200; font-size:15px; overflow:auto"><b>'+mCluster.markers_.length+' Collisions: </b><a href="javascript:void();" onclick="javascript:clusterZoom();">Zoom</a><br><br>';
    bubble+='<div style="font-size:13px">';
    for (i=0; i<mCluster.markers_.length; i++) {
        bubble+='<a href="javascript:void();" onclick="javascript:test('+i+');">'+mCluster.markers_[i].title+'</a><br>';
    }
    bubble+='</div></div>';

    infowindow.setPosition(center);
    infowindow.setContent(bubble);
    infowindow.setSize(infowindow.getSize());           
    infowindow.open(map);
  //

  if (markerClusterer.isZoomOnClick()) {
    // Zoom into the cluster.
    this.map_.fitBounds(this.cluster_.getBounds());
  }
};
// added
function clusterZoom()
{
    infowindow.close();
    map.fitBounds(bounds);
}
// added
function test(index)
{
    infowindow.close();
    var $marker = mCluster.markers_[index];
        // need zoom code here.........

    map.panTo($marker.getPosition());

}

Thanks.

Original issue reported on code.google.com by oshy...@gmail.com on 16 Jun 2011 at 11:15

GoogleCodeExporter commented 8 years ago
In your "test" function you will want to set the map's zoom level to one higher 
than the value of the MarkerClusterer maxZoom parameter. (This assumes you have 
set maxZoom since the default is null.)

Original comment by garylitt...@gmail.com on 26 Jun 2011 at 5:41