1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
function MarkerClusterer(e,t,r){this.extend(MarkerClusterer,google.maps.OverlayView),this.map_=e,this.markers_=[],this.clusters_=[],this.markersCluster_={},this.markersUniqueID=1,this.sizes=[53,56,66,78,90],this.styles_=[],this.cssClass_="",this.cssDefaultClass_="cluster",this.setIndex_=0,this.ready_=!1;var s=r||{};this.gridSize_=void 0!==s.gridSize?s.gridSize:60,this.minClusterSize_=s.minimumClusterSize||2,this.ignoreHiddenMarkers_=s.ignoreHiddenMarkers||!1,this.maxZoom_=s.maxZoom||null,this.styles_=s.styles||[],this.cssClass_=s.cssClass||null,this.imagePath_=s.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=s.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=s.zoomOnClick&&(this.zoomOnClick_=s.zoomOnClick),this.averageCenter_=!1,null!=s.averageCenter&&(this.averageCenter_=s.averageCenter),this.onMouseoverCluster_=s.onMouseoverCluster,this.onMouseoutCluster_=s.onMouseoutCluster,this.drawCluster_=s.drawCluster,this.hideCluster_=s.hideCluster,this.showCluster_=s.showCluster,this.onAddCluster_=s.onAddCluster,this.onRemoveCluster_=s.onRemoveCluster,this.setupStyles_(),this.setMap(e),this.prevZoom_=this.map_.getZoom();var o=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var e=o.map_.getZoom();o.prevZoom_!=e&&(o.prevZoom_=e,o.resetViewport())}),google.maps.event.addListener(this.map_,"idle",function(){o.redraw()}),t&&t.length&&this.addMarkers(t,!1)}function Cluster(e){this.markerClusterer_=e,this.map_=e.getMap(),this.gridSize_=e.getGridSize(),this.minClusterSize_=e.getMinClusterSize(),this.averageCenter_=e.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new ClusterIcon(this,e.getStyles(),e.getGridSize())}function ClusterIcon(e,t,r){e.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView),this.styles_=t,this.padding_=r||0,this.cluster_=e,this.center_=null,this.map_=e.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}function defaultClusterOnAdd(t){if(t.div_=document.createElement("DIV"),t.visible_){var e=t.getPosFromLatLng_(t.center_);t.div_.style.cssText=t.createCss(e),t.div_.innerHTML=t.sums_.text,t.addClass()}t.getPanes().overlayMouseTarget.appendChild(t.div_);var r=!1,s=!1;google.maps.event.addDomListener(t.div_,"click",function(e){r||t.triggerClusterClick(e)}),google.maps.event.addDomListener(t.div_,"mousedown",function(){s=!(r=!1)}),google.maps.event.addDomListener(t.div_,"mouseup",function(){s=r=!1}),google.maps.event.addDomListener(t.div_,"mousemove",function(){s&&(r=!0)}),google.maps.event.addDomListener(t.div_,"mouseover",function(e){t.triggerClusterMouseover(e)}),google.maps.event.addDomListener(t.div_,"mouseout",function(e){t.triggerClusterMouseout(e)})}function defaultClusterDraw(e){if(e.visible_){var t=e.getPosFromLatLng_(e.center_);e.div_.style.top=t.y+"px",e.div_.style.left=t.x+"px"}}function defaultClusterHide(e){e.div_&&(e.div_.style.display="none",e.div_.className=""),e.visible_=!1}function defaultClusterShow(e){if(e.div_){var t=e.getPosFromLatLng_(e.center_);e.div_.style.cssText=e.createCss(t),e.div_.style.display="",e.addClass()}e.visible_=!0}function defaultClusterOnRemove(e){e.div_&&e.div_.parentNode&&(e.hide(),e.div_.parentNode.removeChild(e.div_),e.div_=null)}MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="https://raw.githubusercontent.com/gmaps-marker-clusterer/gmaps-marker-clusterer/master/images/m",MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png",MarkerClusterer.prototype.extend=function(e,t){return function(e){for(var t in e.prototype)this.prototype[t]=e.prototype[t];return this}.apply(e,[t])},MarkerClusterer.prototype.onAdd=function(){this.setReady_(!0)},MarkerClusterer.prototype.draw=function(){},MarkerClusterer.prototype.setupStyles_=function(){if(!this.styles_.length)for(var e,t=0;e=this.sizes[t];t++){var r="";r="function"==typeof this.imagePath_?this.imagePath_(t,e):this.imagePath_+(t+1)+"."+this.imageExtension_,this.styles_.push({url:r,height:e,width:e})}},MarkerClusterer.prototype.fitMapToMarkers=function(){for(var e,t=th
|