Clusterer=function(map){ this.map=map; this.markers=[]; this.clusters=[]; this.timeout=null; this.currentZoomLevel=map.getZoom(); this.maxTabs=Clusterer.defaultMaxTabs; this.link_page=Clusterer.defaultLinkPage; 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.defaultLinkPage=''; Clusterer.defaultMaxTabs=5; Clusterer.defaultMaxVisibleMarkers=150; Clusterer.defaultGridSize=10; Clusterer.defaultMinMarkersPerCluster=5; Clusterer.defaultMaxLinesPerInfoBox=8; Clusterer.defaultIcon=new GIcon(); Clusterer.defaultIcon.image='http://www.acme.com/resources/images/markers/blue_large.PNG'; Clusterer.defaultIcon.shadow='http://www.acme.com/resources/images/markers/shadow_large.PNG'; Clusterer.defaultIcon.iconSize=new GSize(30,51); Clusterer.defaultIcon.shadowSize=new GSize(56,51); Clusterer.defaultIcon.iconAnchor=new GPoint(13,34); Clusterer.defaultIcon.infoWindowAnchor=new GPoint(13,3); Clusterer.defaultIcon.infoShadowAnchor=new GPoint(27,37); Clusterer.prototype.SetIcon=function(icon) {this.icon=icon;}; Clusterer.prototype.SetMaxTabs=function(n) {this.maxTabs=n;}; Clusterer.prototype.SetLinkPage=function(n) {this.link_page=n;}; 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(); }; zoom_map=function(zoom, newLat, newLng){ //map.setCenter(new GLatLng(lat, lng), map.getZoom()+2); map.setZoom(zoom); map.panTo(new GLatLng(newLat, newLng)); }; 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 5 && clusterer.maxTabs > 4) {width = 430;} html='
'; if (clusterer.link_page != ''){ var nelat = -90, nelong = -180, swlat = 90, swlong = 180; for (var j = 0; j < cluster.markers.length; j++){ var lat = cluster.markers[j].getPoint().lat(); var lng = cluster.markers[j].getPoint().lng(); if (lat >= nelat){ nelat = lat; } if (lng >= nelong){ nelong = lng; } if (lat <= swlat){ swlat = lat; } if (lng <= swlong){ swlong = lng; } } var all_images = clusterer.link_page+'1&'+nelat+'&'+nelong+'&'+swlat+'&'+swlong; html += ''; n++; } for(var i=0;i'; } else html+=''; html+=''; if(n/(tab_num+1)==clusterer.maxLinesPerInfoBox-1&&cluster.markerCount+1>clusterer.maxLinesPerInfoBox){ tab_num++; if (tab_num == clusterer.maxTabs){ var nelat = -90, nelong = -180, swlat = 90, swlong = 180; for (var j = 0; j < cluster.markers.length; j++){ var lat = cluster.markers[j].getPoint().lat(); var lng = cluster.markers[j].getPoint().lng(); if (lat >= nelat){ nelat = lat; } if (lng >= nelong){ nelong = lng; } if (lat <= swlat){ swlat = lat; } if (lng <= swlong){ swlong = lng; } } var zoomlvl = Math.min(clusterer.map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(swlat, swlong),new GLatLng(nelat, nelong))), 15); var newLat = (swlat+nelat)/2; var newLng = (swlong+nelong)/2; if ((cluster.markerCount-n) > 0) html+='
View all images in this cluster
'+marker.title+'
Zoomez pour voir les '+(cluster.markerCount-n)+' autre(s) site(s)
'; tabs.push(new GInfoWindowTab(tab_num, html)); html = ''; break; } html+='
'; tabs.push(new GInfoWindowTab(tab_num, html)); html='
'; } } } if (tab_num > 0 && html.length > 26){ html+='
'; tab_num++; tabs.push(new GInfoWindowTab(tab_num, html)); } clusterer.map.closeInfoWindow(); if (n <= clusterer.maxLinesPerInfoBox){ cluster.marker.openInfoWindowHtml(html); } else{ cluster.marker.openInfoWindowTabsHtml(tabs); } clusterer.poppedUpCluster=cluster; }; Clusterer.RePop=function(clusterer){ //if(clusterer.poppedUpCluster!=null) //Clusterer.PopUp(poppedUpCluster); }; Clusterer.PopDown=function(clusterer){ clusterer.poppedUpCluster=null; }; Clusterer.prototype.ClearCluster=function(cluster){ var i,marker; for(i=0;i