Clusterer=function(map) { this.map=map; this.markers=[]; this.clusters=[]; this.timeout=null; this.currentZoomLevel=map.getZoom(); this.maxVisibleMarkers=Clusterer.defaultMaxVisibleMarkers; this.gridSize=Clusterer.defaultGridSize; this.minMarkersPerCluster=Clusterer.defaultMinMarkersPerCluster; this.maxLinesPerInfoBox=Clusterer.defaultMaxLinesPerInfoBox; this.icon=Clusterer.defaultIcon; GEvent.addListener(map,'zoomend',Clusterer.MakeCaller(Clusterer.Display,this)); GEvent.addListener(map,'moveend',Clusterer.MakeCaller(Clusterer.Display,this)); GEvent.addListener(map,'infowindowclose',Clusterer.MakeCaller(Clusterer.PopDown,this)); }; Clusterer.defaultMaxVisibleMarkers=2; Clusterer.defaultGridSize=15; Clusterer.defaultMinMarkersPerCluster=2; Clusterer.defaultMaxLinesPerInfoBox=15; Clusterer.defaultIcon=new GIcon(); Clusterer.defaultIcon.image='http://www.karenbrown.com/images/icons/magnify.png'; Clusterer.defaultIcon.shadow='http://www.karenbrown.com/images/icons/magnifys.png'; Clusterer.defaultIcon.iconSize=new GSize(30,30); Clusterer.defaultIcon.shadowSize=new GSize(60,30); Clusterer.defaultIcon.iconAnchor=new GPoint(15,15); Clusterer.defaultIcon.infoWindowAnchor=new GPoint(15,15); Clusterer.defaultIcon.infoShadowAnchor=new GPoint(15,15); Clusterer.prototype.SetIcon=function(icon) {this.icon=icon;}; Clusterer.prototype.SetMaxVisibleMarkers=function(n) {this.maxVisibleMarkers=n;}; Clusterer.prototype.SetMinMarkersPerCluster=function(n) {this.minMarkersPerCluster=n;}; Clusterer.prototype.SetMaxLinesPerInfoBox=function(n) {this.maxLinesPerInfoBox=n;}; Clusterer.prototype.AddMarker=function(marker,title) {if(marker.setMap!=null) marker.setMap(this.map); marker.title=title; marker.onMap=false; this.markers.push(marker); this.DisplayLater();}; Clusterer.prototype.RemoveMarker=function(marker) {for(var i=0;iclusterer.maxVisibleMarkers) {var latRange=bounds.getNorthEast().lat()-bounds.getSouthWest().lat();var latInc=latRange/clusterer.gridSize;var lngInc=latInc/Math.cos((bounds.getNorthEast().lat()+bounds.getSouthWest().lat())/2.0*Math.PI/180.0);for(var lat=bounds.getSouthWest().lat();lat<=bounds.getNorthEast().lat();lat+=latInc) for(var lng=bounds.getSouthWest().lng();lng<=bounds.getNorthEast().lng();lng+=lngInc) {cluster=new Object();cluster.clusterer=clusterer;cluster.bounds=new GLatLngBounds(new GLatLng(lat,lng),new GLatLng(lat+latInc,lng+lngInc));cluster.markers=[];cluster.markerCount=0;cluster.onMap=false;cluster.marker=null;clusterer.clusters.push(cluster);} for(i=0;i=0;--i) if(clusterer.clusters[i]!=null) break;else --clusterer.clusters.length;for(i=0;i';else html+='';html+=''+marker.title+'';if(n==clusterer.maxLinesPerInfoBox-1&&cluster.markerCount>clusterer.maxLinesPerInfoBox) {html+='...and '+(cluster.markerCount-n)+' more';break;}}} html+='';clusterer.map.closeInfoWindow();cluster.marker.openInfoWindowHtml(html);clusterer.poppedUpCluster=cluster;}; Clusterer.RePop=function(clusterer) {if(clusterer.poppedUpCluster!=null) Clusterer.PopUp(clusterer.poppedUpCluster);}; Clusterer.PopDown=function(clusterer) {clusterer.poppedUpCluster=null;}; Clusterer.prototype.ClearCluster=function(cluster) {var i,marker;for(i=0;i