function MarkerClusterer(_1,_2,_3){
var _4=[];
var _5=_1;
var _6=null;
var _7=this;
var _8=60;
var _9=[53,56,66,78,90];
var _a=[];
var _b=[];
var _c=null;
var _d=true;
var _e=function(_f){
var _10=0;
var _11=_f.length;
var dv=_11;
while(dv!==0){
dv=parseInt(dv/10,10);
_10++;
}
var _13=this.getStyles().length;
if(_13<_10){
_10=_13;
}
return {"text":_11,"index":_10};
};
var i=0;
for(i=1;i<=5;++i){
_a.push({"url":"http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/images/m"+i+".png","height":_9[i-1],"width":_9[i-1]});
}
if(typeof _3==="object"&&_3!==null){
if(typeof _3.gridSize==="number"&&_3.gridSize>0){
_8=_3.gridSize;
}
if(typeof _3.maxZoom==="number"){
_6=_3.maxZoom;
}
if(typeof _3.styles==="object"&&_3.styles!==null&&_3.styles.length!==0){
_a=_3.styles;
}
if(typeof _3.calculator==="function"){
_e=_3.calculator;
}
if(typeof _3.zoomOnClick==="boolean"){
_d=_3.zoomOnClick;
}
}
this.setCalculator=function(_15){
_e=_15;
};
this.getCalculator=function(){
return GEvent.callback(this,_e);
};
this.isZoomOnClick=function(){
return _d;
};
function addLeftMarkers_(){
if(_b.length===0){
return;
}
var _16=[];
for(i=0;i<_b.length;++i){
if(isMarkerInViewport_(_b[i])){
_7.addMarker(_b[i],true,null,null,true);
}else{
_16.push(_b[i]);
}
}
_b=_16;
}
this.getStyles=function(){
return _a;
};
this.clearMarkers=function(){
for(var i=0;i<_4.length;++i){
if(typeof _4[i]!=="undefined"&&_4[i]!==null){
_4[i].clearMarkers();
}
}
_4=[];
_b=[];
};
function isMarkerInViewport_(_18){
return _5.getBounds().containsLatLng(_18.getLatLng());
}
function reAddMarkers_(_19){
var len=_19.length;
var _1b=[];
for(var i=len-1;i>=0;--i){
_7.addMarker(_19[i].marker,true,_19[i].isAdded,_1b,true);
}
addLeftMarkers_();
}
this.addMarker=function(_1d,_1e,_1f,_20,_21){
if(_21!==true){
if(!isMarkerInViewport_(_1d)){
_b.push(_1d);
return;
}
}
var _22=_1f;
var _23=_20;
var pos=_5.fromLatLngToDivPixel(_1d.getLatLng());
if(typeof _22!=="boolean"){
_22=false;
}
if(typeof _23!=="object"||_23===null){
_23=_4;
}
var _25=_23.length;
var _26=null;
for(var i=_25-1;i>=0;i--){
_26=_23[i];
var _28=_26.getCenter();
if(_28===null){
continue;
}
_28=_5.fromLatLngToDivPixel(_28);
if(pos.x>=_28.x-_8&&pos.x<=_28.x+_8&&pos.y>=_28.y-_8&&pos.y<=_28.y+_8){
_26.addMarker({"isAdded":_22,"marker":_1d});
if(!_1e){
_26.redraw_();
}
return;
}
}
_26=new Cluster(this,_1);
_26.addMarker({"isAdded":_22,"marker":_1d});
if(!_1e){
_26.redraw_();
}
_23.push(_26);
if(_23!==_4){
_4.push(_26);
}
};
this.removeMarker=function(_29){
for(var i=0;i<_4.length;++i){
if(_4[i]&&_4[i].removeMarker(_29)){
_4[i].redraw_();
return;
}
}
};
this.redraw_=function(){
var _2b=this.getClustersInViewport_();
for(var i=0;i<_2b.length;++i){
_2b[i].redraw_(true);
}
};
this.getClustersInViewport_=function(){
var _2d=[];
var _2e=_5.getBounds();
for(var i=0;i<_4.length;i++){
if(_4[i].isInBounds(_2e)){
_2d.push(_4[i]);
}
}
return _2d;
};
this.getMaxZoom_=function(){
return _6;
};
this.getMap_=function(){
return _5;
};
this.getGridSize_=function(){
return _8;
};
this.getTotalMarkers=function(){
var _30=0;
for(var i=0;i<_4.length;++i){
_30+=_4[i].getTotalMarkers();
}
return _30;
};
this.getTotalClusters=function(){
return _4.length;
};
this.resetViewport=function(){
var _32=this.getClustersInViewport_();
var _33=[];
var _34=0;
for(var i=0;i<_32.length;++i){
var _36=_32[i];
var _37=_36.getCurrentZoom();
if(_37===null){
continue;
}
var _38=_5.getZoom();
if(_38!==_37){
var mks=_36.getMarkers();
for(var j=0;j<mks.length;++j){
var _3b={"isAdded":false,"marker":mks[j].marker};
_33.push(_3b);
}
_36.clearMarkers();
_34++;
for(j=0;j<_4.length;++j){
if(_36===_4[j]){
_4.splice(j,1);
}
}
}
}
reAddMarkers_(_33);
this.redraw_();
};
this.addMarkers=function(_3c){
for(var i=0;i<_3c.length;++i){
this.addMarker(_3c[i],true);
}
this.redraw_();
};
this.getParentCluster=function(_3e){
return _3e.parentCluster_;
};
if(typeof _2==="object"&&_2!==null){
this.addMarkers(_2);
}
_c=GEvent.addListener(_5,"moveend",function(){
_7.resetViewport();
});
}
function Cluster(_3f){
var _40=null;
var _41=[];
var _42=_3f;
var _43=_3f.getMap_();
var _44=null;
var _45=_43.getZoom();
var _46=this;
this.getMarkers=function(){
return _41;
};
this.getMarkerClusterer=function(){
return _42;
};
this.isInBounds=function(_47){
if(_40===null){
return false;
}
if(!_47){
_47=_43.getBounds();
}
var sw=_43.fromLatLngToDivPixel(_47.getSouthWest());
var ne=_43.fromLatLngToDivPixel(_47.getNorthEast());
var _4a=_43.fromLatLngToDivPixel(_40);
var _4b=true;
var _4c=_3f.getGridSize_();
if(_45!==_43.getZoom()){
var dl=_43.getZoom()-_45;
_4c=Math.pow(2,dl)*_4c;
}
if(ne.x!==sw.x&&(_4a.x+_4c<sw.x||_4a.x-_4c>ne.x)){
_4b=false;
}
if(_4b&&(_4a.y+_4c<ne.y||_4a.y-_4c>sw.y)){
_4b=false;
}
return _4b;
};
this.getCenter=function(){
return _40;
};
this.addMarker=function(_4e){
if(_40===null){
_40=_4e.marker.getLatLng();
}
_4e.marker.parentCluster_=_46;
_41.push(_4e);
};
this.removeMarker=function(_4f){
for(var i=0;i<_41.length;++i){
if(_4f===_41[i].marker){
if(_41[i].isAdded){
_43.removeOverlay(_41[i].marker);
}
delete _41[i].marker.parentCluster_;
_41.splice(i,1);
return true;
}
}
return false;
};
this.getCurrentZoom=function(){
return _45;
};
this.redraw_=function(_51){
if(!_51&&!this.isInBounds()){
return;
}
_45=_43.getZoom();
var i=0;
var mz=_3f.getMaxZoom_();
if(mz===null){
mz=_43.getCurrentMapType().getMaximumResolution();
}
if(_45>mz||this.getTotalMarkers()===1){
for(i=0;i<_41.length;++i){
if(_41[i].isAdded){
if(_41[i].marker.isHidden()){
_41[i].marker.show();
}
}else{
_43.addOverlay(_41[i].marker);
_41[i].isAdded=true;
}
}
if(_44!==null){
_44.hide();
}
}else{
if(this.getTotalMarkers()>1){
for(i=0;i<_41.length;++i){
if(_41[i].isAdded&&(!_41[i].marker.isHidden())){
_41[i].marker.hide();
}
}
var _54=_42.getCalculator()(this.getRealMarkers());
if(_44===null){
_44=new ClusterMarker_(_40,_54,_42.getStyles(),_42.getGridSize_(),_46);
_43.addOverlay(_44);
}else{
if(_44.isHidden()){
_44.show();
}
_44.setSums(_54);
_44.redraw(true);
}
}
}
};
this.clearMarkers=function(){
if(_44!==null){
_43.removeOverlay(_44);
}
for(var i=0;i<_41.length;++i){
if(_41[i].isAdded){
_43.removeOverlay(_41[i].marker);
}
delete _41[i].marker.parentCluster_;
}
_41=[];
};
this.getTotalMarkers=function(){
return _41.length;
};
this.getRealMarkers=function(){
var _56=[];
for(var i=0;i<_41.length;++i){
_56.push(_41[i].marker);
}
return _56;
};
}
function ClusterMarker_(_58,_59,_5a,_5b,_5c){
var _5d=_59.index;
this.useStyle(_5a[_5d-1]);
this.styleDirty_=false;
this.latlng_=_58;
this.index_=_5d;
this.styles_=_5a;
this.text_=_59.text;
this.padding_=_5b;
this.sums_=_59;
this.cluster_=_5c;
}
ClusterMarker_.prototype=new GOverlay();
ClusterMarker_.prototype.useStyle=function(_5e){
this.url_=_5e.url;
this.height_=_5e.height;
this.width_=_5e.width;
this.textColor_=_5e.opt_textColor;
this.anchor_=_5e.opt_anchor;
this.textSize_=_5e.opt_textSize;
};
ClusterMarker_.prototype.initialize=function(map){
this.map_=map;
var div=document.createElement("div");
var _61=this.latlng_;
var pos=this.getPosFromLatLng(_61);
div.style.cssText=this.createCss(pos);
div.innerHTML=this.text_;
map.getPane(G_MAP_MAP_PANE).appendChild(div);
var _63=this.padding_;
var _64=this.cluster_;
GEvent.addDomListener(div,"click",function(){
GEvent.trigger(_64.getMarkerClusterer(),"clusterclick",_64);
if(_64.getMarkerClusterer().isZoomOnClick()){
var pos=map.fromLatLngToDivPixel(_61);
var sw=new GPoint(pos.x-_63,pos.y+_63);
sw=map.fromDivPixelToLatLng(sw);
var ne=new GPoint(pos.x+_63,pos.y-_63);
ne=map.fromDivPixelToLatLng(ne);
var _68=map.getBoundsZoomLevel(new GLatLngBounds(sw,ne),map.getSize());
map.setCenter(_61,_68);
}
});
this.div_=div;
};
ClusterMarker_.prototype.getPosFromLatLng=function(_69){
var pos=this.map_.fromLatLngToDivPixel(_69);
pos.x-=parseInt(this.width_/2,10);
pos.y-=parseInt(this.height_/2,10);
return pos;
};
ClusterMarker_.prototype.createCss=function(pos){
var _6c="";
if(document.all){
_6c="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\""+this.url_+"\");";
}else{
_6c="background:url("+this.url_+");";
}
if(typeof this.anchor_==="object"){
if(typeof this.anchor_[0]==="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_){
_6c+="height:"+(this.height_-this.anchor_[0])+"px;padding-top:"+this.anchor_[0]+"px;";
}else{
_6c+="height:"+this.height_+"px;line-height:"+this.height_+"px;";
}
if(typeof this.anchor_[1]==="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_){
_6c+="width:"+(this.width_-this.anchor_[1])+"px;padding-left:"+this.anchor_[1]+"px;";
}else{
_6c+="width:"+this.width_+"px;text-align:center;";
}
}else{
_6c+="height:"+this.height_+"px;line-height:"+this.height_+"px;";
_6c+="width:"+this.width_+"px;text-align:center;";
}
var _6d=this.textColor_?this.textColor_:"black";
var _6e=this.textSize_?this.textSize_:11;
return _6c+"cursor:pointer;top:"+pos.y+"px;left:"+pos.x+"px;color:"+_6d+";position:absolute;font-size:"+_6e+"px;"+"font-family:Arial,sans-serif;font-weight:bold";
};
ClusterMarker_.prototype.remove=function(){
this.div_.parentNode.removeChild(this.div_);
};
ClusterMarker_.prototype.copy=function(){
return new ClusterMarker_(this.latlng_,this.sums_,this.text_,this.styles_,this.padding_,this.cluster_);
};
ClusterMarker_.prototype.redraw=function(_6f){
if(!_6f){
return;
}
var pos=this.getPosFromLatLng(this.latlng_);
if(this.styleDirty_){
this.styleDirty_=false;
this.useStyle(this.styles_[this.index_-1]);
this.div_.style.cssText=this.createCss(pos);
}else{
this.div_.style.top=pos.y+"px";
this.div_.style.left=pos.x+"px";
}
};
ClusterMarker_.prototype.hide=function(){
this.div_.style.display="none";
};
ClusterMarker_.prototype.show=function(){
this.div_.style.display="";
};
ClusterMarker_.prototype.isHidden=function(){
return this.div_.style.display==="none";
};
ClusterMarker_.prototype.setSums=function(_71){
if(_71.index!==this.index_){
this.styleDirty_=true;
}
this.sums_=_71;
this.text_=_71.text;
this.index_=_71.index;
this.div_.innerHTML=_71.text;
};


