var BMapLib=window.BMapLib=BMapLib||{};!function(){function Cluster(markerClusterer){this._markerClusterer=markerClusterer,this._map=markerClusterer.getMap(),this._minClusterSize=markerClusterer.getMinClusterSize(),this._isAverageCenter=markerClusterer.isAverageCenter(),this._center=null,this._markers=[],this._gridBounds=null,this._isReal=!1,this._clusterMarker=new BMapLib.TextIconOverlay(this._center,this._markers.length,{styles:this._markerClusterer.getStyles()})}var getExtendedBounds=function(map,bounds,gridSize){bounds=cutBoundsInRange(bounds);var pixelNE=map.pointToPixel(bounds.getNorthEast()),pixelSW=map.pointToPixel(bounds.getSouthWest());pixelNE.x+=gridSize,pixelNE.y-=gridSize,pixelSW.x-=gridSize,pixelSW.y+=gridSize;var newNE=map.pixelToPoint(pixelNE),newSW=map.pixelToPoint(pixelSW);return new BMap.Bounds(newSW,newNE)},cutBoundsInRange=function(bounds){var maxX=getRange(bounds.getNorthEast().lng,-180,180),minX=getRange(bounds.getSouthWest().lng,-180,180),maxY=getRange(bounds.getNorthEast().lat,-74,74),minY=getRange(bounds.getSouthWest().lat,-74,74);return new BMap.Bounds(new BMap.Point(minX,minY),new BMap.Point(maxX,maxY))},getRange=function(i,mix,max){return mix&&(i=Math.max(i,mix)),max&&(i=Math.min(i,max)),i},isArray=function(source){return"[object Array]"===Object.prototype.toString.call(source)},indexOf=function(item,source){var index=-1;if(isArray(source))if(source.indexOf)index=source.indexOf(item);else for(var m,i=0;m=source[i];i++)if(m===item){index=i;break}return index},MarkerClusterer=BMapLib.MarkerClusterer=function(map,options){if(map){this._map=map,this._markers=[],this._clusters=[];var opts=options||{};this._gridSize=opts.gridSize||60,this._maxZoom=opts.maxZoom||18,this._minClusterSize=opts.minClusterSize||2,this._isAverageCenter=!1,void 0!=opts.isAverageCenter&&(this._isAverageCenter=opts.isAverageCenter),this._styles=opts.styles||[];var that=this;this._map.addEventListener("zoomend",function(){that._redraw()}),this._map.addEventListener("moveend",function(){that._redraw()});var mkrs=opts.markers;isArray(mkrs)&&this.addMarkers(mkrs)}};MarkerClusterer.prototype.addMarkers=function(markers){for(var i=0,len=markers.length;ithis._markerClusterer.getMaxZoom()){this._clusterMarker&&this._map.removeOverlay(this._clusterMarker);for(var marker,i=0;marker=this._markers[i];i++)this._map.addOverlay(marker)}else{if(this._markers.length