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 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;
}
}
function _d(){
if(_b.length===0){
return;
}
var _e=[];
for(i=0;i<_b.length;++i){
_7.addMarker(_b[i],true,null,null,true);
}
_b=_e;
};
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=[];
GEvent.removeListener(_c);
};
function _f(_10){
return _5.getBounds().containsLatLng(_10.getLatLng());
};
function _11(_12){
var len=_12.length;
var _13=[];
for(var i=len-1;i>=0;--i){
_7.addMarker(_12[i].marker,true,_12[i].isAdded,_13,true);
}
_d();
};
this.addMarker=function(_14,_15,_16,_17,_18){
if(_18!==true){
if(!_f(_14)){
_b.push(_14);
return;
}
}
var _19=_16;
var _1a=_17;
var pos=_5.fromLatLngToDivPixel(_14.getLatLng());
if(typeof _19!=="boolean"){
_19=false;
}
if(typeof _1a!=="object"||_1a===null){
_1a=_4;
}
var _1b=_1a.length;
var _1c=null;
for(var i=_1b-1;i>=0;i--){
_1c=_1a[i];
var _1d=_1c.getCenter();
if(_1d===null){
continue;
}
_1d=_5.fromLatLngToDivPixel(_1d);
if(pos.x>=_1d.x-_8&&pos.x<=_1d.x+_8&&pos.y>=_1d.y-_8&&pos.y<=_1d.y+_8){
_1c.addMarker({"isAdded":_19,"marker":_14});
if(!_15){
_1c.redraw_();
}
return;
}
}
_1c=new Cluster(this,_1);
_1c.addMarker({"isAdded":_19,"marker":_14});
if(!_15){
_1c.redraw_();
}
_1a.push(_1c);
if(_1a!==_4){
_4.push(_1c);
}
};
this.removeMarker=function(_1e){
for(var i=0;i<_4.length;++i){
if(_4[i].remove(_1e)){
_4[i].redraw_();
return;
}
}
};
this.redraw_=function(){
var _1f=this.getClustersInViewport_();
for(var i=0;i<_1f.length;++i){
_1f[i].redraw_(true);
}
};
this.getClustersInViewport_=function(){
var _20=[];
var _21=_5.getBounds();
for(var i=0;i<_4.length;i++){
if(_4[i].isInBounds(_21)){
_20.push(_4[i]);
}
}
return _20;
};
this.getMaxZoom_=function(){
return _6;
};
this.getMap_=function(){
return _5;
};
this.getGridSize_=function(){
return _8;
};
this.getTotalMarkers=function(){
var _22=0;
for(var i=0;i<_4.length;++i){
_22+=_4[i].getTotalMarkers();
}
return _22;
};
this.getTotalClusters=function(){
return _4.length;
};
this.resetViewport=function(){
var _23=this.getClustersInViewport_();
var _24=[];
var _25=0;
for(var i=0;i<_23.length;++i){
var _26=_23[i];
var _27=_26.getCurrentZoom();
if(_27===null){
continue;
}
var _28=_5.getZoom();
if(_28!==_27){
var mks=_26.getMarkers();
for(var j=0;j<mks.length;++j){
var _29={"isAdded":false,"marker":mks[j].marker};
_24.push(_29);
}
_26.clearMarkers();
_25++;
for(j=0;j<_4.length;++j){
if(_26===_4[j]){
_4.splice(j,1);
}
}
}
}
_11(_24);
this.redraw_();
};
this.addMarkers=function(_2a){
for(var i=0;i<_2a.length;++i){
this.addMarker(_2a[i],true);
}
this.redraw_();
};
if(typeof _2==="object"&&_2!==null){
this.addMarkers(_2);
}
_c=GEvent.addListener(_5,"moveend",function(){
_7.resetViewport();
});
};
function Cluster(_2b){
var _2c=null;
var _2d=[];
var _2e=_2b;
var _2f=_2b.getMap_();
var _30=null;
var _31=_2f.getZoom();
this.getMarkers=function(){
return _2d;
};
this.isInBounds=function(_32){
if(_2c===null){
return false;
}
if(!_32){
_32=_2f.getBounds();
}
var sw=_2f.fromLatLngToDivPixel(_32.getSouthWest());
var ne=_2f.fromLatLngToDivPixel(_32.getNorthEast());
var _33=_2f.fromLatLngToDivPixel(_2c);
var _34=true;
var _35=_2b.getGridSize_();
if(_31!==_2f.getZoom()){
var dl=_2f.getZoom()-_31;
_35=Math.pow(2,dl)*_35;
}
if(ne.x!==sw.x&&(_33.x+_35<sw.x||_33.x-_35>ne.x)){
_34=false;
}
if(_34&&(_33.y+_35<ne.y||_33.y-_35>sw.y)){
_34=false;
}
return _34;
};
this.getCenter=function(){
return _2c;
};
this.addMarker=function(_36){
if(_2c===null){
_2c=_36.marker.getLatLng();
}
_2d.push(_36);
};
this.removeMarker=function(_37){
for(var i=0;i<_2d.length;++i){
if(_37===_2d[i].marker){
if(_2d[i].isAdded){
_2f.removeOverlay(_2d[i].marker);
}
_2d.splice(i,1);
return true;
}
}
return false;
};
this.getCurrentZoom=function(){
return _31;
};
this.redraw_=function(_38){
if(!_38&&!this.isInBounds()){
return;
}
_31=_2f.getZoom();
var i=0;
var mz=_2b.getMaxZoom_();
if(mz===null){
mz=_2f.getCurrentMapType().getMaximumResolution();
}
if(_31>=mz||this.getTotalMarkers()===1){
for(i=0;i<_2d.length;++i){
if(_2d[i].isAdded){
if(_2d[i].marker.isHidden()){
_2d[i].marker.show();
}
}else{
_2f.addOverlay(_2d[i].marker);
_2d[i].isAdded=true;
}
}
if(_30!==null){
_30.hide();
}
}else{
for(i=0;i<_2d.length;++i){
if(_2d[i].isAdded&&(!_2d[i].marker.isHidden())){
_2d[i].marker.hide();
}
}
if(_30===null){
_30=new ClusterMarker_(_2c,this.getTotalMarkers(),_2e.getStyles_(),_2e.getGridSize_());
_2f.addOverlay(_30);
}else{
if(_30.isHidden()){
_30.show();
}
_30.redraw(true);
}
}
};
this.clearMarkers=function(){
if(_30!==null){
_2f.removeOverlay(_30);
}
for(var i=0;i<_2d.length;++i){
if(_2d[i].isAdded){
_2f.removeOverlay(_2d[i].marker);
}
}
_2d=[];
};
this.getTotalMarkers=function(){
return _2d.length;
};
};
function ClusterMarker_(_39,_3a,_3b,_3c){
var _3d=0;
var dv=_3a;
while(dv!==0){
dv=parseInt(dv/10,10);
_3d++;
}
if(_3b.length<_3d){
_3d=_3b.length;
}
this.url_=_3b[_3d-1].url;
this.height_=_3b[_3d-1].height;
this.width_=_3b[_3d-1].width;
this.textColor_=_3b[_3d-1].opt_textColor;
this.anchor_=_3b[_3d-1].opt_anchor;
this.latlng_=_39;
this.index_=_3d;
this.styles_=_3b;
this.text_=_3a;
this.padding_=_3c;
};
ClusterMarker_.prototype=new GOverlay();
ClusterMarker_.prototype.initialize=function(map){
this.map_=map;
var div=document.createElement("div");
var _3e=this.latlng_;
var pos=map.fromLatLngToDivPixel(_3e);
pos.x-=parseInt(this.width_/2,10);
pos.y-=parseInt(this.height_/2,10);
var _3f="";
if(document.all){
_3f="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\""+this.url_+"\");";
}else{
_3f="background:url("+this.url_+");";
}
if(typeof this.anchor_==="object"){
if(typeof this.anchor_[0]==="number"&&this.anchor_[0]>0&&this.anchor_[0]<this.height_){
_3f+="height:"+(this.height_-this.anchor_[0])+"px;padding-top:"+this.anchor_[0]+"px;";
}else{
_3f+="height:"+this.height_+"px;line-height:"+this.height_+"px;";
}
if(typeof this.anchor_[1]==="number"&&this.anchor_[1]>0&&this.anchor_[1]<this.width_){
_3f+="width:"+(this.width_-this.anchor_[1])+"px;padding-left:"+this.anchor_[1]+"px;";
}else{
_3f+="width:"+this.width_+"px;text-align:center;";
}
}else{
_3f+="height:"+this.height_+"px;line-height:"+this.height_+"px;";
_3f+="width:"+this.width_+"px;text-align:center;";
}
var _40=this.textColor_?this.textColor_:"black";
div.style.cssText=_3f+"cursor:pointer;top:"+pos.y+"px;left:"+pos.x+"px;color:"+_40+";position:absolute;font-size:11px;"+"font-family:Arial,sans-serif;font-weight:bold";
div.innerHTML=this.text_;
map.getPane(G_MAP_MAP_PANE).appendChild(div);
var _41=this.padding_;
GEvent.addDomListener(div,"click",function(){
var pos=map.fromLatLngToDivPixel(_3e);
var sw=new GPoint(pos.x-_41,pos.y+_41);
sw=map.fromDivPixelToLatLng(sw);
var ne=new GPoint(pos.x+_41,pos.y-_41);
ne=map.fromDivPixelToLatLng(ne);
var _42=map.getBoundsZoomLevel(new GLatLngBounds(sw,ne),map.getSize());
map.setCenter(_3e,_42);
});
this.div_=div;
};
ClusterMarker_.prototype.remove=function(){
this.div_.parentNode.removeChild(this.div_);
};
ClusterMarker_.prototype.copy=function(){
return new ClusterMarker_(this.latlng_,this.index_,this.text_,this.styles_,this.padding_);
};
ClusterMarker_.prototype.redraw=function(_43){
if(!_43){
return;
}
var pos=this.map_.fromLatLngToDivPixel(this.latlng_);
pos.x-=parseInt(this.width_/2,10);
pos.y-=parseInt(this.height_/2,10);
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";
};


