@react-google-maps/marker-clusterer
Advanced tools
Comparing version 2.11.8 to 2.14.0
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var ClusterIcon = /** @class */ (function () { | ||
@@ -167,5 +165,7 @@ function ClusterIcon(cluster, styles) { | ||
ClusterIcon.prototype.show = function () { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
if (this.div && this.center) { | ||
var divTitle = ''; | ||
var divTitle = this.sums === null || | ||
typeof this.sums.title === 'undefined' || | ||
this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title; | ||
// NOTE: values must be specified in px units | ||
@@ -176,17 +176,4 @@ var bp = this.backgroundPosition.split(' '); | ||
var pos = this.getPosFromLatLng(this.center); | ||
if (this.sums === null || | ||
typeof this.sums.title === 'undefined' || | ||
this.sums.title === '') { | ||
divTitle = this.cluster.getClusterer().getTitle(); | ||
} | ||
else { | ||
divTitle = this.sums.title; | ||
} | ||
this.div.className = this.className; | ||
this.div.style.cursor = 'pointer'; | ||
this.div.style.position = 'absolute'; | ||
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0'; | ||
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0'; | ||
this.div.style.width = "".concat(this.width, "px"); | ||
this.div.style.height = "".concat(this.height, "px"); | ||
this.div.setAttribute('style', "cursor: 'pointer'; position: 'absolute'; top: ".concat(pos !== null ? "".concat(pos.y, "px") : '0', "; left: ").concat(pos !== null ? "".concat(pos.x, "px") : '0', "; width: ").concat(this.width, "px; height: ").concat(this.height, "px; ")); | ||
var img = document.createElement('img'); | ||
@@ -197,5 +184,3 @@ img.alt = divTitle; | ||
img.height = this.height; | ||
img.style.position = 'absolute'; | ||
img.style.top = "".concat(spriteV, "px"); | ||
img.style.left = "".concat(spriteH, "px"); | ||
img.setAttribute('style', "position: absolute; top: ".concat(spriteV, "px; left: ").concat(spriteH, "px")); | ||
if (!this.cluster.getClusterer().enableRetinaIcons) { | ||
@@ -205,15 +190,7 @@ img.style.clip = "rect(-".concat(spriteV, "px, -").concat(spriteH + this.width, "px, -").concat(spriteV + this.height, ", -").concat(spriteH, ")"); | ||
var textElm = document.createElement('div'); | ||
textElm.style.position = 'absolute'; | ||
textElm.style.top = "".concat(this.anchorText[0], "px"); | ||
textElm.style.left = "".concat(this.anchorText[1], "px"); | ||
textElm.style.color = this.textColor; | ||
textElm.style.fontSize = "".concat(this.textSize, "px"); | ||
textElm.style.fontFamily = this.fontFamily; | ||
textElm.style.fontWeight = this.fontWeight; | ||
textElm.style.fontStyle = this.fontStyle; | ||
textElm.style.textDecoration = this.textDecoration; | ||
textElm.style.textAlign = 'center'; | ||
textElm.style.width = "".concat(this.width, "px"); | ||
textElm.style.lineHeight = "".concat(this.height, "px"); | ||
textElm.innerText = "".concat((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text); | ||
textElm.setAttribute('style', "position: absolute; top: ".concat(this.anchorText[0], "px; left: ").concat(this.anchorText[1], "px; color: ").concat(this.textColor, "; font-size: ").concat(this.textSize, "px; font-family: ").concat(this.fontFamily, "; font-weight: ").concat(this.fontWeight, "; fontStyle: ").concat(this.fontStyle, "; text-decoration: ").concat(this.textDecoration, "; text-align: center; width: ").concat(this.width, "px; line-height: ").concat(this.height, "px")); | ||
if ((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text) | ||
textElm.innerText = "".concat((_b = this.sums) === null || _b === void 0 ? void 0 : _b.text); | ||
if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.html) | ||
textElm.innerHTML = "".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.html); | ||
this.div.innerHTML = ''; | ||
@@ -220,0 +197,0 @@ this.div.appendChild(img); |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(e,i){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=i,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(t){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var e=this.cluster.getClusterer();if(google.maps.event.trigger(e,"click",this.cluster),google.maps.event.trigger(e,"clusterclick",this.cluster),e.getZoomOnClick()){var i=e.getMaxZoom(),s=this.cluster.getBounds(),n=e.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var n=t.getZoom()||0;null!==i&&n>i&&t.setZoom(i+1)}}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var t;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),null===(t=this.getPanes())||void 0===t||t.overlayMouseTarget.appendChild(this.div);var e=this.getMap();null!==e&&(this.boundsChangedListener=google.maps.event.addListener(e,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),null!==this.boundsChangedListener&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),null!==this.timeOut&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&null!==this.div&&this.center){var t=this.getPosFromLatLng(this.center);this.div.style.top=null!==t?"".concat(t.y,"px"):"0",this.div.style.left=null!==t?"".concat(t.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var t;if(this.div&&this.center){var e="",i=this.backgroundPosition.split(" "),s=parseInt(i[0].replace(/^\s+|\s+$/g,""),10),n=parseInt(i[1].replace(/^\s+|\s+$/g,""),10),r=this.getPosFromLatLng(this.center);e=null===this.sums||void 0===this.sums.title||""===this.sums.title?this.cluster.getClusterer().getTitle():this.sums.title,this.div.className=this.className,this.div.style.cursor="pointer",this.div.style.position="absolute",this.div.style.top=null!==r?"".concat(r.y,"px"):"0",this.div.style.left=null!==r?"".concat(r.x,"px"):"0",this.div.style.width="".concat(this.width,"px"),this.div.style.height="".concat(this.height,"px");var o=document.createElement("img");o.alt=e,o.src=this.url,o.width=this.width,o.height=this.height,o.style.position="absolute",o.style.top="".concat(n,"px"),o.style.left="".concat(s,"px"),this.cluster.getClusterer().enableRetinaIcons||(o.style.clip="rect(-".concat(n,"px, -").concat(s+this.width,"px, -").concat(n+this.height,", -").concat(s,")"));var h=document.createElement("div");h.style.position="absolute",h.style.top="".concat(this.anchorText[0],"px"),h.style.left="".concat(this.anchorText[1],"px"),h.style.color=this.textColor,h.style.fontSize="".concat(this.textSize,"px"),h.style.fontFamily=this.fontFamily,h.style.fontWeight=this.fontWeight,h.style.fontStyle=this.fontStyle,h.style.textDecoration=this.textDecoration,h.style.textAlign="center",h.style.width="".concat(this.width,"px"),h.style.lineHeight="".concat(this.height,"px"),h.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(h),this.div.title=e,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(t){this.sums=t;var e=this.cluster.getClusterer().getStyles(),i=e[Math.min(e.length-1,Math.max(0,t.index-1))];this.url=i.url,this.height=i.height,this.width=i.width,i.className&&(this.className="".concat(this.clusterClassName," ").concat(i.className)),this.anchorText=i.anchorText||[0,0],this.anchorIcon=i.anchorIcon||[this.height/2,this.width/2],this.textColor=i.textColor||"black",this.textSize=i.textSize||11,this.textDecoration=i.textDecoration||"none",this.fontWeight=i.fontWeight||"bold",this.fontStyle=i.fontStyle||"normal",this.fontFamily=i.fontFamily||"Arial,sans-serif",this.backgroundPosition=i.backgroundPosition||"0 0"},t.prototype.setCenter=function(t){this.center=t},t.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},t}(),e=function(){function e(e){this.markerClusterer=e,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new t(this,this.markerClusterer.getStyles()),this.getSize=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return e.prototype.getSize=function(){return this.markers.length},e.prototype.getMarkers=function(){return this.markers},e.prototype.getCenter=function(){return this.center},e.prototype.getMap=function(){return this.map},e.prototype.getClusterer=function(){return this.markerClusterer},e.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center,this.center),e=this.getMarkers(),i=0;i<e.length;i++){var s=e[i].getPosition();s&&t.extend(s)}return t},e.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},e.prototype.addMarker=function(t){var e,i;if(this.isMarkerAlreadyAdded(t))return!1;if(this.center){if(this.averageCenter&&(i=t.getPosition())){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+i.lat())/s,(this.center.lng()*(s-1)+i.lng())/s),this.calculateBounds()}}else(i=t.getPosition())&&(this.center=i,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var n=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(n<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(n===this.minClusterSize)for(var h=0;h<n;h++)this.markers[h].setMap(null);else t.setMap(null);return!0},e.prototype.isMarkerInClusterBounds=function(t){if(null!==this.bounds){var e=t.getPosition();if(e)return this.bounds.contains(e)}return!1},e.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},e.prototype.updateIcon=function(){var t,e=this.markers.length,i=this.markerClusterer.getMaxZoom(),s=null===(t=this.map)||void 0===t?void 0:t.getZoom();null!==i&&void 0!==s&&s>i||e<this.minClusterSize?this.clusterIcon.hide():(this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show())},e.prototype.isMarkerAlreadyAdded=function(t){if(this.markers.includes)return this.markers.includes(t);for(var e=0;e<this.markers.length;e++)if(t===this.markers[e])return!0;return!1},e}();function i(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}}var s=[53,56,66,78,90],n=function(){function t(e,n,r){void 0===n&&(n=[]),void 0===r&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createClusters=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.extend=this.extend.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,void 0!==r.zoomOnClick&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,void 0!==r.averageCenter&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,void 0!==r.ignoreHidden&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=r.imageExtension||"png",this.imageSizes=r.imageSizes||s,this.calculator=r.calculator||i,this.batchSize=r.batchSize||2e3,this.batchSizeIE=r.batchSizeIE||500,this.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(n,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var t,e;this.resetViewport(!1),(null===(t=this.getMap())||void 0===t?void 0:t.getZoom())!==(this.get("minZoom")||0)&&(null===(e=this.getMap())||void 0===e?void 0:e.getZoom())!==this.get("maxZoom")||google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var t=this.getMap();this.activeMap=t,this.ready=!0,this.repaint(),null!==t&&(this.listeners=[google.maps.event.addListener(t,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(t,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var t=0;t<this.markers.length;t++)this.markers[t].getMap()!==this.activeMap&&this.markers[t].setMap(this.activeMap);for(t=0;t<this.clusters.length;t++)this.clusters[t].remove();this.clusters=[];for(t=0;t<this.listeners.length;t++)google.maps.event.removeListener(this.listeners[t]);this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:"".concat(this.imagePath+(t+1),".").concat(this.imageExtension),height:this.imageSizes[t],width:this.imageSizes[t]})},t.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0;i<t.length;i++){var s=t[i].getPosition();s&&e.extend(s)}var n=this.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(e)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(t){this.gridSize=t},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(t){this.maxZoom=t},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(t){this.styles=t},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(t){this.title=t},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(t){this.averageCenter=t},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(t){this.imageExtension=t},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(t){this.imagePath=t},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(t){this.imageSizes=t},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(t){this.calculator=t},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(t){this.clusterClass=t},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},t.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},t.prototype.pushMarkerTo=function(t){var e=this;t.getDraggable()&&google.maps.event.addListener(t,"dragend",(function(){e.ready&&(t.isAdded=!1,e.repaint())})),t.isAdded=!1,this.markers.push(t)},t.prototype.removeMarker_=function(t){var e=-1;if(this.markers.indexOf)e=this.markers.indexOf(t);else for(var i=0;i<this.markers.length;i++)if(t===this.markers[i]){e=i;break}return-1!==e&&(t.setMap(null),this.markers.splice(e,1),!0)},t.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},t.prototype.removeMarkers=function(t,e){for(var i=!1,s=0;s<t.length;s++)i=i||this.removeMarker_(t[s]);return!e&&i&&this.repaint(),i},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},t.prototype.repaint=function(){var t=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout((function(){for(var e=0;e<t.length;e++)t[e].remove()}),0)},t.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()));null!==i&&(i.x+=this.gridSize,i.y-=this.gridSize);var s=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()));if(null!==s&&(s.x-=this.gridSize,s.y+=this.gridSize),null!==i){var n=e.fromDivPixelToLatLng(i);null!==n&&t.extend(n)}if(null!==s){var r=e.fromDivPixelToLatLng(s);null!==r&&t.extend(r)}return t},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(t){for(var e=0;e<this.clusters.length;e++)this.clusters[e].remove();this.clusters=[];for(e=0;e<this.markers.length;e++){var i=this.markers[e];i.isAdded=!1,t&&i.setMap(null)}},t.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,n=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371},t.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},t.prototype.addToClosestCluster=function(t){for(var i,s=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(i=this.clusters[r]).getCenter(),h=t.getPosition();if(o&&h){var a=this.distanceBetweenPoints(o,h);a<s&&(s=a,n=i)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((i=new e(this)).addMarker(t),this.clusters.push(i))},t.prototype.createClusters=function(t){var e=this;if(this.ready){0===t&&(google.maps.event.trigger(this,"clusteringbegin",this),null!==this.timerRefStatic&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var i=this.getMap(),s=(null!==i&&"getBounds"in i?i.getBounds():null),n=((null==i?void 0:i.getZoom())||0)>3?new google.maps.LatLngBounds(null==s?void 0:s.getSouthWest(),null==s?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),r=this.getExtendedBounds(n),o=Math.min(t+this.batchSize,this.markers.length),h=t;h<o;h++){var a=this.markers[h];!a.isAdded&&this.isMarkerInBounds(a,r)&&(!this.ignoreHidden||this.ignoreHidden&&a.getVisible())&&this.addToClosestCluster(a)}if(o<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(o)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(h=0;h<this.clusters.length;h++)this.clusters[h].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])},t}();exports.Cluster=e,exports.ClusterIcon=t,exports.Clusterer=n; | ||
"use strict";var t=function(){function t(e,i){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=i,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(t){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var e=this.cluster.getClusterer();if(google.maps.event.trigger(e,"click",this.cluster),google.maps.event.trigger(e,"clusterclick",this.cluster),e.getZoomOnClick()){var i=e.getMaxZoom(),s=this.cluster.getBounds(),n=e.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var n=t.getZoom()||0;null!==i&&n>i&&t.setZoom(i+1)}}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var t;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),null===(t=this.getPanes())||void 0===t||t.overlayMouseTarget.appendChild(this.div);var e=this.getMap();null!==e&&(this.boundsChangedListener=google.maps.event.addListener(e,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),null!==this.boundsChangedListener&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),null!==this.timeOut&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&null!==this.div&&this.center){var t=this.getPosFromLatLng(this.center);this.div.style.top=null!==t?"".concat(t.y,"px"):"0",this.div.style.left=null!==t?"".concat(t.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var t,e,i,s;if(this.div&&this.center){var n=null===this.sums||void 0===this.sums.title||""===this.sums.title?this.cluster.getClusterer().getTitle():this.sums.title,r=this.backgroundPosition.split(" "),o=parseInt(r[0].replace(/^\s+|\s+$/g,""),10),h=parseInt(r[1].replace(/^\s+|\s+$/g,""),10),a=this.getPosFromLatLng(this.center);this.div.className=this.className,this.div.setAttribute("style","cursor: 'pointer'; position: 'absolute'; top: ".concat(null!==a?"".concat(a.y,"px"):"0","; left: ").concat(null!==a?"".concat(a.x,"px"):"0","; width: ").concat(this.width,"px; height: ").concat(this.height,"px; "));var l=document.createElement("img");l.alt=n,l.src=this.url,l.width=this.width,l.height=this.height,l.setAttribute("style","position: absolute; top: ".concat(h,"px; left: ").concat(o,"px")),this.cluster.getClusterer().enableRetinaIcons||(l.style.clip="rect(-".concat(h,"px, -").concat(o+this.width,"px, -").concat(h+this.height,", -").concat(o,")"));var u=document.createElement("div");u.setAttribute("style","position: absolute; top: ".concat(this.anchorText[0],"px; left: ").concat(this.anchorText[1],"px; color: ").concat(this.textColor,"; font-size: ").concat(this.textSize,"px; font-family: ").concat(this.fontFamily,"; font-weight: ").concat(this.fontWeight,"; fontStyle: ").concat(this.fontStyle,"; text-decoration: ").concat(this.textDecoration,"; text-align: center; width: ").concat(this.width,"px; line-height: ").concat(this.height,"px")),(null===(t=this.sums)||void 0===t?void 0:t.text)&&(u.innerText="".concat(null===(e=this.sums)||void 0===e?void 0:e.text)),(null===(i=this.sums)||void 0===i?void 0:i.html)&&(u.innerHTML="".concat(null===(s=this.sums)||void 0===s?void 0:s.html)),this.div.innerHTML="",this.div.appendChild(l),this.div.appendChild(u),this.div.title=n,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(t){this.sums=t;var e=this.cluster.getClusterer().getStyles(),i=e[Math.min(e.length-1,Math.max(0,t.index-1))];this.url=i.url,this.height=i.height,this.width=i.width,i.className&&(this.className="".concat(this.clusterClassName," ").concat(i.className)),this.anchorText=i.anchorText||[0,0],this.anchorIcon=i.anchorIcon||[this.height/2,this.width/2],this.textColor=i.textColor||"black",this.textSize=i.textSize||11,this.textDecoration=i.textDecoration||"none",this.fontWeight=i.fontWeight||"bold",this.fontStyle=i.fontStyle||"normal",this.fontFamily=i.fontFamily||"Arial,sans-serif",this.backgroundPosition=i.backgroundPosition||"0 0"},t.prototype.setCenter=function(t){this.center=t},t.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},t}(),e=function(){function e(e){this.markerClusterer=e,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new t(this,this.markerClusterer.getStyles()),this.getSize=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return e.prototype.getSize=function(){return this.markers.length},e.prototype.getMarkers=function(){return this.markers},e.prototype.getCenter=function(){return this.center},e.prototype.getMap=function(){return this.map},e.prototype.getClusterer=function(){return this.markerClusterer},e.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center,this.center),e=this.getMarkers(),i=0;i<e.length;i++){var s=e[i].getPosition();s&&t.extend(s)}return t},e.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},e.prototype.addMarker=function(t){var e,i;if(this.isMarkerAlreadyAdded(t))return!1;if(this.center){if(this.averageCenter&&(i=t.getPosition())){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+i.lat())/s,(this.center.lng()*(s-1)+i.lng())/s),this.calculateBounds()}}else(i=t.getPosition())&&(this.center=i,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var n=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(n<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(n===this.minClusterSize)for(var h=0;h<n;h++)this.markers[h].setMap(null);else t.setMap(null);return!0},e.prototype.isMarkerInClusterBounds=function(t){if(null!==this.bounds){var e=t.getPosition();if(e)return this.bounds.contains(e)}return!1},e.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},e.prototype.updateIcon=function(){var t,e=this.markers.length,i=this.markerClusterer.getMaxZoom(),s=null===(t=this.map)||void 0===t?void 0:t.getZoom();null!==i&&void 0!==s&&s>i||e<this.minClusterSize?this.clusterIcon.hide():(this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show())},e.prototype.isMarkerAlreadyAdded=function(t){if(this.markers.includes)return this.markers.includes(t);for(var e=0;e<this.markers.length;e++)if(t===this.markers[e])return!0;return!1},e}();function i(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}}var s=[53,56,66,78,90],n=function(){function t(e,n,r){void 0===n&&(n=[]),void 0===r&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createClusters=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.extend=this.extend.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,void 0!==r.zoomOnClick&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,void 0!==r.averageCenter&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,void 0!==r.ignoreHidden&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=r.imageExtension||"png",this.imageSizes=r.imageSizes||s,this.calculator=r.calculator||i,this.batchSize=r.batchSize||2e3,this.batchSizeIE=r.batchSizeIE||500,this.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(n,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var t,e;this.resetViewport(!1),(null===(t=this.getMap())||void 0===t?void 0:t.getZoom())!==(this.get("minZoom")||0)&&(null===(e=this.getMap())||void 0===e?void 0:e.getZoom())!==this.get("maxZoom")||google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var t=this.getMap();this.activeMap=t,this.ready=!0,this.repaint(),null!==t&&(this.listeners=[google.maps.event.addListener(t,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(t,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var t=0;t<this.markers.length;t++)this.markers[t].getMap()!==this.activeMap&&this.markers[t].setMap(this.activeMap);for(t=0;t<this.clusters.length;t++)this.clusters[t].remove();this.clusters=[];for(t=0;t<this.listeners.length;t++)google.maps.event.removeListener(this.listeners[t]);this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:"".concat(this.imagePath+(t+1),".").concat(this.imageExtension),height:this.imageSizes[t],width:this.imageSizes[t]})},t.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0;i<t.length;i++){var s=t[i].getPosition();s&&e.extend(s)}var n=this.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(e)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(t){this.gridSize=t},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(t){this.maxZoom=t},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(t){this.styles=t},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(t){this.title=t},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(t){this.averageCenter=t},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(t){this.imageExtension=t},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(t){this.imagePath=t},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(t){this.imageSizes=t},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(t){this.calculator=t},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(t){this.clusterClass=t},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},t.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},t.prototype.pushMarkerTo=function(t){var e=this;t.getDraggable()&&google.maps.event.addListener(t,"dragend",(function(){e.ready&&(t.isAdded=!1,e.repaint())})),t.isAdded=!1,this.markers.push(t)},t.prototype.removeMarker_=function(t){var e=-1;if(this.markers.indexOf)e=this.markers.indexOf(t);else for(var i=0;i<this.markers.length;i++)if(t===this.markers[i]){e=i;break}return-1!==e&&(t.setMap(null),this.markers.splice(e,1),!0)},t.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},t.prototype.removeMarkers=function(t,e){for(var i=!1,s=0;s<t.length;s++)i=i||this.removeMarker_(t[s]);return!e&&i&&this.repaint(),i},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},t.prototype.repaint=function(){var t=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout((function(){for(var e=0;e<t.length;e++)t[e].remove()}),0)},t.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()));null!==i&&(i.x+=this.gridSize,i.y-=this.gridSize);var s=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()));if(null!==s&&(s.x-=this.gridSize,s.y+=this.gridSize),null!==i){var n=e.fromDivPixelToLatLng(i);null!==n&&t.extend(n)}if(null!==s){var r=e.fromDivPixelToLatLng(s);null!==r&&t.extend(r)}return t},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(t){for(var e=0;e<this.clusters.length;e++)this.clusters[e].remove();this.clusters=[];for(e=0;e<this.markers.length;e++){var i=this.markers[e];i.isAdded=!1,t&&i.setMap(null)}},t.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,n=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371},t.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},t.prototype.addToClosestCluster=function(t){for(var i,s=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(i=this.clusters[r]).getCenter(),h=t.getPosition();if(o&&h){var a=this.distanceBetweenPoints(o,h);a<s&&(s=a,n=i)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((i=new e(this)).addMarker(t),this.clusters.push(i))},t.prototype.createClusters=function(t){var e=this;if(this.ready){0===t&&(google.maps.event.trigger(this,"clusteringbegin",this),null!==this.timerRefStatic&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var i=this.getMap(),s=(null!==i&&"getBounds"in i?i.getBounds():null),n=((null==i?void 0:i.getZoom())||0)>3?new google.maps.LatLngBounds(null==s?void 0:s.getSouthWest(),null==s?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),r=this.getExtendedBounds(n),o=Math.min(t+this.batchSize,this.markers.length),h=t;h<o;h++){var a=this.markers[h];!a.isAdded&&this.isMarkerInBounds(a,r)&&(!this.ignoreHidden||this.ignoreHidden&&a.getVisible())&&this.addToClosestCluster(a)}if(o<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(o)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(h=0;h<this.clusters.length;h++)this.clusters[h].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])},t}();exports.Cluster=e,exports.ClusterIcon=t,exports.Clusterer=n; | ||
//# sourceMappingURL=cjs.min.js.map |
@@ -163,5 +163,7 @@ var ClusterIcon = /** @class */ (function () { | ||
ClusterIcon.prototype.show = function () { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
if (this.div && this.center) { | ||
var divTitle = ''; | ||
var divTitle = this.sums === null || | ||
typeof this.sums.title === 'undefined' || | ||
this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title; | ||
// NOTE: values must be specified in px units | ||
@@ -172,17 +174,4 @@ var bp = this.backgroundPosition.split(' '); | ||
var pos = this.getPosFromLatLng(this.center); | ||
if (this.sums === null || | ||
typeof this.sums.title === 'undefined' || | ||
this.sums.title === '') { | ||
divTitle = this.cluster.getClusterer().getTitle(); | ||
} | ||
else { | ||
divTitle = this.sums.title; | ||
} | ||
this.div.className = this.className; | ||
this.div.style.cursor = 'pointer'; | ||
this.div.style.position = 'absolute'; | ||
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0'; | ||
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0'; | ||
this.div.style.width = "".concat(this.width, "px"); | ||
this.div.style.height = "".concat(this.height, "px"); | ||
this.div.setAttribute('style', "cursor: 'pointer'; position: 'absolute'; top: ".concat(pos !== null ? "".concat(pos.y, "px") : '0', "; left: ").concat(pos !== null ? "".concat(pos.x, "px") : '0', "; width: ").concat(this.width, "px; height: ").concat(this.height, "px; ")); | ||
var img = document.createElement('img'); | ||
@@ -193,5 +182,3 @@ img.alt = divTitle; | ||
img.height = this.height; | ||
img.style.position = 'absolute'; | ||
img.style.top = "".concat(spriteV, "px"); | ||
img.style.left = "".concat(spriteH, "px"); | ||
img.setAttribute('style', "position: absolute; top: ".concat(spriteV, "px; left: ").concat(spriteH, "px")); | ||
if (!this.cluster.getClusterer().enableRetinaIcons) { | ||
@@ -201,15 +188,7 @@ img.style.clip = "rect(-".concat(spriteV, "px, -").concat(spriteH + this.width, "px, -").concat(spriteV + this.height, ", -").concat(spriteH, ")"); | ||
var textElm = document.createElement('div'); | ||
textElm.style.position = 'absolute'; | ||
textElm.style.top = "".concat(this.anchorText[0], "px"); | ||
textElm.style.left = "".concat(this.anchorText[1], "px"); | ||
textElm.style.color = this.textColor; | ||
textElm.style.fontSize = "".concat(this.textSize, "px"); | ||
textElm.style.fontFamily = this.fontFamily; | ||
textElm.style.fontWeight = this.fontWeight; | ||
textElm.style.fontStyle = this.fontStyle; | ||
textElm.style.textDecoration = this.textDecoration; | ||
textElm.style.textAlign = 'center'; | ||
textElm.style.width = "".concat(this.width, "px"); | ||
textElm.style.lineHeight = "".concat(this.height, "px"); | ||
textElm.innerText = "".concat((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text); | ||
textElm.setAttribute('style', "position: absolute; top: ".concat(this.anchorText[0], "px; left: ").concat(this.anchorText[1], "px; color: ").concat(this.textColor, "; font-size: ").concat(this.textSize, "px; font-family: ").concat(this.fontFamily, "; font-weight: ").concat(this.fontWeight, "; fontStyle: ").concat(this.fontStyle, "; text-decoration: ").concat(this.textDecoration, "; text-align: center; width: ").concat(this.width, "px; line-height: ").concat(this.height, "px")); | ||
if ((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text) | ||
textElm.innerText = "".concat((_b = this.sums) === null || _b === void 0 ? void 0 : _b.text); | ||
if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.html) | ||
textElm.innerHTML = "".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.html); | ||
this.div.innerHTML = ''; | ||
@@ -216,0 +195,0 @@ this.div.appendChild(img); |
@@ -1,2 +0,2 @@ | ||
var t=function(){function t(e,i){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=i,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(t){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var e=this.cluster.getClusterer();if(google.maps.event.trigger(e,"click",this.cluster),google.maps.event.trigger(e,"clusterclick",this.cluster),e.getZoomOnClick()){var i=e.getMaxZoom(),s=this.cluster.getBounds(),n=e.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var n=t.getZoom()||0;null!==i&&n>i&&t.setZoom(i+1)}}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var t;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),null===(t=this.getPanes())||void 0===t||t.overlayMouseTarget.appendChild(this.div);var e=this.getMap();null!==e&&(this.boundsChangedListener=google.maps.event.addListener(e,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),null!==this.boundsChangedListener&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),null!==this.timeOut&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&null!==this.div&&this.center){var t=this.getPosFromLatLng(this.center);this.div.style.top=null!==t?"".concat(t.y,"px"):"0",this.div.style.left=null!==t?"".concat(t.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var t;if(this.div&&this.center){var e="",i=this.backgroundPosition.split(" "),s=parseInt(i[0].replace(/^\s+|\s+$/g,""),10),n=parseInt(i[1].replace(/^\s+|\s+$/g,""),10),r=this.getPosFromLatLng(this.center);e=null===this.sums||void 0===this.sums.title||""===this.sums.title?this.cluster.getClusterer().getTitle():this.sums.title,this.div.className=this.className,this.div.style.cursor="pointer",this.div.style.position="absolute",this.div.style.top=null!==r?"".concat(r.y,"px"):"0",this.div.style.left=null!==r?"".concat(r.x,"px"):"0",this.div.style.width="".concat(this.width,"px"),this.div.style.height="".concat(this.height,"px");var o=document.createElement("img");o.alt=e,o.src=this.url,o.width=this.width,o.height=this.height,o.style.position="absolute",o.style.top="".concat(n,"px"),o.style.left="".concat(s,"px"),this.cluster.getClusterer().enableRetinaIcons||(o.style.clip="rect(-".concat(n,"px, -").concat(s+this.width,"px, -").concat(n+this.height,", -").concat(s,")"));var h=document.createElement("div");h.style.position="absolute",h.style.top="".concat(this.anchorText[0],"px"),h.style.left="".concat(this.anchorText[1],"px"),h.style.color=this.textColor,h.style.fontSize="".concat(this.textSize,"px"),h.style.fontFamily=this.fontFamily,h.style.fontWeight=this.fontWeight,h.style.fontStyle=this.fontStyle,h.style.textDecoration=this.textDecoration,h.style.textAlign="center",h.style.width="".concat(this.width,"px"),h.style.lineHeight="".concat(this.height,"px"),h.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(h),this.div.title=e,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(t){this.sums=t;var e=this.cluster.getClusterer().getStyles(),i=e[Math.min(e.length-1,Math.max(0,t.index-1))];this.url=i.url,this.height=i.height,this.width=i.width,i.className&&(this.className="".concat(this.clusterClassName," ").concat(i.className)),this.anchorText=i.anchorText||[0,0],this.anchorIcon=i.anchorIcon||[this.height/2,this.width/2],this.textColor=i.textColor||"black",this.textSize=i.textSize||11,this.textDecoration=i.textDecoration||"none",this.fontWeight=i.fontWeight||"bold",this.fontStyle=i.fontStyle||"normal",this.fontFamily=i.fontFamily||"Arial,sans-serif",this.backgroundPosition=i.backgroundPosition||"0 0"},t.prototype.setCenter=function(t){this.center=t},t.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},t}(),e=function(){function e(e){this.markerClusterer=e,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new t(this,this.markerClusterer.getStyles()),this.getSize=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return e.prototype.getSize=function(){return this.markers.length},e.prototype.getMarkers=function(){return this.markers},e.prototype.getCenter=function(){return this.center},e.prototype.getMap=function(){return this.map},e.prototype.getClusterer=function(){return this.markerClusterer},e.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center,this.center),e=this.getMarkers(),i=0;i<e.length;i++){var s=e[i].getPosition();s&&t.extend(s)}return t},e.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},e.prototype.addMarker=function(t){var e,i;if(this.isMarkerAlreadyAdded(t))return!1;if(this.center){if(this.averageCenter&&(i=t.getPosition())){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+i.lat())/s,(this.center.lng()*(s-1)+i.lng())/s),this.calculateBounds()}}else(i=t.getPosition())&&(this.center=i,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var n=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(n<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(n===this.minClusterSize)for(var h=0;h<n;h++)this.markers[h].setMap(null);else t.setMap(null);return!0},e.prototype.isMarkerInClusterBounds=function(t){if(null!==this.bounds){var e=t.getPosition();if(e)return this.bounds.contains(e)}return!1},e.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},e.prototype.updateIcon=function(){var t,e=this.markers.length,i=this.markerClusterer.getMaxZoom(),s=null===(t=this.map)||void 0===t?void 0:t.getZoom();null!==i&&void 0!==s&&s>i||e<this.minClusterSize?this.clusterIcon.hide():(this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show())},e.prototype.isMarkerAlreadyAdded=function(t){if(this.markers.includes)return this.markers.includes(t);for(var e=0;e<this.markers.length;e++)if(t===this.markers[e])return!0;return!1},e}();function i(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}}var s=[53,56,66,78,90],n=function(){function t(e,n,r){void 0===n&&(n=[]),void 0===r&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createClusters=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.extend=this.extend.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,void 0!==r.zoomOnClick&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,void 0!==r.averageCenter&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,void 0!==r.ignoreHidden&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=r.imageExtension||"png",this.imageSizes=r.imageSizes||s,this.calculator=r.calculator||i,this.batchSize=r.batchSize||2e3,this.batchSizeIE=r.batchSizeIE||500,this.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(n,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var t,e;this.resetViewport(!1),(null===(t=this.getMap())||void 0===t?void 0:t.getZoom())!==(this.get("minZoom")||0)&&(null===(e=this.getMap())||void 0===e?void 0:e.getZoom())!==this.get("maxZoom")||google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var t=this.getMap();this.activeMap=t,this.ready=!0,this.repaint(),null!==t&&(this.listeners=[google.maps.event.addListener(t,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(t,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var t=0;t<this.markers.length;t++)this.markers[t].getMap()!==this.activeMap&&this.markers[t].setMap(this.activeMap);for(t=0;t<this.clusters.length;t++)this.clusters[t].remove();this.clusters=[];for(t=0;t<this.listeners.length;t++)google.maps.event.removeListener(this.listeners[t]);this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:"".concat(this.imagePath+(t+1),".").concat(this.imageExtension),height:this.imageSizes[t],width:this.imageSizes[t]})},t.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0;i<t.length;i++){var s=t[i].getPosition();s&&e.extend(s)}var n=this.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(e)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(t){this.gridSize=t},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(t){this.maxZoom=t},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(t){this.styles=t},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(t){this.title=t},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(t){this.averageCenter=t},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(t){this.imageExtension=t},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(t){this.imagePath=t},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(t){this.imageSizes=t},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(t){this.calculator=t},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(t){this.clusterClass=t},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},t.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},t.prototype.pushMarkerTo=function(t){var e=this;t.getDraggable()&&google.maps.event.addListener(t,"dragend",(function(){e.ready&&(t.isAdded=!1,e.repaint())})),t.isAdded=!1,this.markers.push(t)},t.prototype.removeMarker_=function(t){var e=-1;if(this.markers.indexOf)e=this.markers.indexOf(t);else for(var i=0;i<this.markers.length;i++)if(t===this.markers[i]){e=i;break}return-1!==e&&(t.setMap(null),this.markers.splice(e,1),!0)},t.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},t.prototype.removeMarkers=function(t,e){for(var i=!1,s=0;s<t.length;s++)i=i||this.removeMarker_(t[s]);return!e&&i&&this.repaint(),i},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},t.prototype.repaint=function(){var t=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout((function(){for(var e=0;e<t.length;e++)t[e].remove()}),0)},t.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()));null!==i&&(i.x+=this.gridSize,i.y-=this.gridSize);var s=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()));if(null!==s&&(s.x-=this.gridSize,s.y+=this.gridSize),null!==i){var n=e.fromDivPixelToLatLng(i);null!==n&&t.extend(n)}if(null!==s){var r=e.fromDivPixelToLatLng(s);null!==r&&t.extend(r)}return t},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(t){for(var e=0;e<this.clusters.length;e++)this.clusters[e].remove();this.clusters=[];for(e=0;e<this.markers.length;e++){var i=this.markers[e];i.isAdded=!1,t&&i.setMap(null)}},t.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,n=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371},t.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},t.prototype.addToClosestCluster=function(t){for(var i,s=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(i=this.clusters[r]).getCenter(),h=t.getPosition();if(o&&h){var a=this.distanceBetweenPoints(o,h);a<s&&(s=a,n=i)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((i=new e(this)).addMarker(t),this.clusters.push(i))},t.prototype.createClusters=function(t){var e=this;if(this.ready){0===t&&(google.maps.event.trigger(this,"clusteringbegin",this),null!==this.timerRefStatic&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var i=this.getMap(),s=(null!==i&&"getBounds"in i?i.getBounds():null),n=((null==i?void 0:i.getZoom())||0)>3?new google.maps.LatLngBounds(null==s?void 0:s.getSouthWest(),null==s?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),r=this.getExtendedBounds(n),o=Math.min(t+this.batchSize,this.markers.length),h=t;h<o;h++){var a=this.markers[h];!a.isAdded&&this.isMarkerInBounds(a,r)&&(!this.ignoreHidden||this.ignoreHidden&&a.getVisible())&&this.addToClosestCluster(a)}if(o<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(o)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(h=0;h<this.clusters.length;h++)this.clusters[h].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])},t}();export{e as Cluster,t as ClusterIcon,n as Clusterer}; | ||
var t=function(){function t(e,i){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=i,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(t){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var e=this.cluster.getClusterer();if(google.maps.event.trigger(e,"click",this.cluster),google.maps.event.trigger(e,"clusterclick",this.cluster),e.getZoomOnClick()){var i=e.getMaxZoom(),s=this.cluster.getBounds(),n=e.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var n=t.getZoom()||0;null!==i&&n>i&&t.setZoom(i+1)}}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var t;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),null===(t=this.getPanes())||void 0===t||t.overlayMouseTarget.appendChild(this.div);var e=this.getMap();null!==e&&(this.boundsChangedListener=google.maps.event.addListener(e,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),null!==this.boundsChangedListener&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),null!==this.timeOut&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&null!==this.div&&this.center){var t=this.getPosFromLatLng(this.center);this.div.style.top=null!==t?"".concat(t.y,"px"):"0",this.div.style.left=null!==t?"".concat(t.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var t,e,i,s;if(this.div&&this.center){var n=null===this.sums||void 0===this.sums.title||""===this.sums.title?this.cluster.getClusterer().getTitle():this.sums.title,r=this.backgroundPosition.split(" "),o=parseInt(r[0].replace(/^\s+|\s+$/g,""),10),h=parseInt(r[1].replace(/^\s+|\s+$/g,""),10),a=this.getPosFromLatLng(this.center);this.div.className=this.className,this.div.setAttribute("style","cursor: 'pointer'; position: 'absolute'; top: ".concat(null!==a?"".concat(a.y,"px"):"0","; left: ").concat(null!==a?"".concat(a.x,"px"):"0","; width: ").concat(this.width,"px; height: ").concat(this.height,"px; "));var l=document.createElement("img");l.alt=n,l.src=this.url,l.width=this.width,l.height=this.height,l.setAttribute("style","position: absolute; top: ".concat(h,"px; left: ").concat(o,"px")),this.cluster.getClusterer().enableRetinaIcons||(l.style.clip="rect(-".concat(h,"px, -").concat(o+this.width,"px, -").concat(h+this.height,", -").concat(o,")"));var u=document.createElement("div");u.setAttribute("style","position: absolute; top: ".concat(this.anchorText[0],"px; left: ").concat(this.anchorText[1],"px; color: ").concat(this.textColor,"; font-size: ").concat(this.textSize,"px; font-family: ").concat(this.fontFamily,"; font-weight: ").concat(this.fontWeight,"; fontStyle: ").concat(this.fontStyle,"; text-decoration: ").concat(this.textDecoration,"; text-align: center; width: ").concat(this.width,"px; line-height: ").concat(this.height,"px")),(null===(t=this.sums)||void 0===t?void 0:t.text)&&(u.innerText="".concat(null===(e=this.sums)||void 0===e?void 0:e.text)),(null===(i=this.sums)||void 0===i?void 0:i.html)&&(u.innerHTML="".concat(null===(s=this.sums)||void 0===s?void 0:s.html)),this.div.innerHTML="",this.div.appendChild(l),this.div.appendChild(u),this.div.title=n,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(t){this.sums=t;var e=this.cluster.getClusterer().getStyles(),i=e[Math.min(e.length-1,Math.max(0,t.index-1))];this.url=i.url,this.height=i.height,this.width=i.width,i.className&&(this.className="".concat(this.clusterClassName," ").concat(i.className)),this.anchorText=i.anchorText||[0,0],this.anchorIcon=i.anchorIcon||[this.height/2,this.width/2],this.textColor=i.textColor||"black",this.textSize=i.textSize||11,this.textDecoration=i.textDecoration||"none",this.fontWeight=i.fontWeight||"bold",this.fontStyle=i.fontStyle||"normal",this.fontFamily=i.fontFamily||"Arial,sans-serif",this.backgroundPosition=i.backgroundPosition||"0 0"},t.prototype.setCenter=function(t){this.center=t},t.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},t}(),e=function(){function e(e){this.markerClusterer=e,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new t(this,this.markerClusterer.getStyles()),this.getSize=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return e.prototype.getSize=function(){return this.markers.length},e.prototype.getMarkers=function(){return this.markers},e.prototype.getCenter=function(){return this.center},e.prototype.getMap=function(){return this.map},e.prototype.getClusterer=function(){return this.markerClusterer},e.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center,this.center),e=this.getMarkers(),i=0;i<e.length;i++){var s=e[i].getPosition();s&&t.extend(s)}return t},e.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},e.prototype.addMarker=function(t){var e,i;if(this.isMarkerAlreadyAdded(t))return!1;if(this.center){if(this.averageCenter&&(i=t.getPosition())){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+i.lat())/s,(this.center.lng()*(s-1)+i.lng())/s),this.calculateBounds()}}else(i=t.getPosition())&&(this.center=i,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var n=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(n<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(n===this.minClusterSize)for(var h=0;h<n;h++)this.markers[h].setMap(null);else t.setMap(null);return!0},e.prototype.isMarkerInClusterBounds=function(t){if(null!==this.bounds){var e=t.getPosition();if(e)return this.bounds.contains(e)}return!1},e.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},e.prototype.updateIcon=function(){var t,e=this.markers.length,i=this.markerClusterer.getMaxZoom(),s=null===(t=this.map)||void 0===t?void 0:t.getZoom();null!==i&&void 0!==s&&s>i||e<this.minClusterSize?this.clusterIcon.hide():(this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show())},e.prototype.isMarkerAlreadyAdded=function(t){if(this.markers.includes)return this.markers.includes(t);for(var e=0;e<this.markers.length;e++)if(t===this.markers[e])return!0;return!1},e}();function i(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}}var s=[53,56,66,78,90],n=function(){function t(e,n,r){void 0===n&&(n=[]),void 0===r&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createClusters=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.extend=this.extend.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,void 0!==r.zoomOnClick&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,void 0!==r.averageCenter&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,void 0!==r.ignoreHidden&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=r.imageExtension||"png",this.imageSizes=r.imageSizes||s,this.calculator=r.calculator||i,this.batchSize=r.batchSize||2e3,this.batchSizeIE=r.batchSizeIE||500,this.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(n,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var t,e;this.resetViewport(!1),(null===(t=this.getMap())||void 0===t?void 0:t.getZoom())!==(this.get("minZoom")||0)&&(null===(e=this.getMap())||void 0===e?void 0:e.getZoom())!==this.get("maxZoom")||google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var t=this.getMap();this.activeMap=t,this.ready=!0,this.repaint(),null!==t&&(this.listeners=[google.maps.event.addListener(t,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(t,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var t=0;t<this.markers.length;t++)this.markers[t].getMap()!==this.activeMap&&this.markers[t].setMap(this.activeMap);for(t=0;t<this.clusters.length;t++)this.clusters[t].remove();this.clusters=[];for(t=0;t<this.listeners.length;t++)google.maps.event.removeListener(this.listeners[t]);this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:"".concat(this.imagePath+(t+1),".").concat(this.imageExtension),height:this.imageSizes[t],width:this.imageSizes[t]})},t.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0;i<t.length;i++){var s=t[i].getPosition();s&&e.extend(s)}var n=this.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(e)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(t){this.gridSize=t},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(t){this.maxZoom=t},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(t){this.styles=t},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(t){this.title=t},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(t){this.averageCenter=t},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(t){this.imageExtension=t},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(t){this.imagePath=t},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(t){this.imageSizes=t},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(t){this.calculator=t},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(t){this.clusterClass=t},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},t.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},t.prototype.pushMarkerTo=function(t){var e=this;t.getDraggable()&&google.maps.event.addListener(t,"dragend",(function(){e.ready&&(t.isAdded=!1,e.repaint())})),t.isAdded=!1,this.markers.push(t)},t.prototype.removeMarker_=function(t){var e=-1;if(this.markers.indexOf)e=this.markers.indexOf(t);else for(var i=0;i<this.markers.length;i++)if(t===this.markers[i]){e=i;break}return-1!==e&&(t.setMap(null),this.markers.splice(e,1),!0)},t.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},t.prototype.removeMarkers=function(t,e){for(var i=!1,s=0;s<t.length;s++)i=i||this.removeMarker_(t[s]);return!e&&i&&this.repaint(),i},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},t.prototype.repaint=function(){var t=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout((function(){for(var e=0;e<t.length;e++)t[e].remove()}),0)},t.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()));null!==i&&(i.x+=this.gridSize,i.y-=this.gridSize);var s=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()));if(null!==s&&(s.x-=this.gridSize,s.y+=this.gridSize),null!==i){var n=e.fromDivPixelToLatLng(i);null!==n&&t.extend(n)}if(null!==s){var r=e.fromDivPixelToLatLng(s);null!==r&&t.extend(r)}return t},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(t){for(var e=0;e<this.clusters.length;e++)this.clusters[e].remove();this.clusters=[];for(e=0;e<this.markers.length;e++){var i=this.markers[e];i.isAdded=!1,t&&i.setMap(null)}},t.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,n=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371},t.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},t.prototype.addToClosestCluster=function(t){for(var i,s=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(i=this.clusters[r]).getCenter(),h=t.getPosition();if(o&&h){var a=this.distanceBetweenPoints(o,h);a<s&&(s=a,n=i)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((i=new e(this)).addMarker(t),this.clusters.push(i))},t.prototype.createClusters=function(t){var e=this;if(this.ready){0===t&&(google.maps.event.trigger(this,"clusteringbegin",this),null!==this.timerRefStatic&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var i=this.getMap(),s=(null!==i&&"getBounds"in i?i.getBounds():null),n=((null==i?void 0:i.getZoom())||0)>3?new google.maps.LatLngBounds(null==s?void 0:s.getSouthWest(),null==s?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),r=this.getExtendedBounds(n),o=Math.min(t+this.batchSize,this.markers.length),h=t;h<o;h++){var a=this.markers[h];!a.isAdded&&this.isMarkerInBounds(a,r)&&(!this.ignoreHidden||this.ignoreHidden&&a.getVisible())&&this.addToClosestCluster(a)}if(o<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(o)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(h=0;h<this.clusters.length;h++)this.clusters[h].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])},t}();export{e as Cluster,t as ClusterIcon,n as Clusterer}; | ||
//# sourceMappingURL=esm.min.js.map |
interface ClusterIconInfo { | ||
text: string; | ||
index: number; | ||
title: string; | ||
title?: string; | ||
html?: string; | ||
} | ||
declare type MarkerExtended = google.maps.Marker & { | ||
type MarkerExtended = google.maps.Marker & { | ||
isAdded?: boolean; | ||
}; | ||
declare type TCalculator = (markers: MarkerExtended[], num: number) => ClusterIconInfo; | ||
type TCalculator = (markers: MarkerExtended[], num: number) => ClusterIconInfo; | ||
interface ClusterIconStyle { | ||
@@ -11,0 +12,0 @@ url: string; |
@@ -169,5 +169,7 @@ (function (global, factory) { | ||
ClusterIcon.prototype.show = function () { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
if (this.div && this.center) { | ||
var divTitle = ''; | ||
var divTitle = this.sums === null || | ||
typeof this.sums.title === 'undefined' || | ||
this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title; | ||
// NOTE: values must be specified in px units | ||
@@ -178,17 +180,4 @@ var bp = this.backgroundPosition.split(' '); | ||
var pos = this.getPosFromLatLng(this.center); | ||
if (this.sums === null || | ||
typeof this.sums.title === 'undefined' || | ||
this.sums.title === '') { | ||
divTitle = this.cluster.getClusterer().getTitle(); | ||
} | ||
else { | ||
divTitle = this.sums.title; | ||
} | ||
this.div.className = this.className; | ||
this.div.style.cursor = 'pointer'; | ||
this.div.style.position = 'absolute'; | ||
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0'; | ||
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0'; | ||
this.div.style.width = "".concat(this.width, "px"); | ||
this.div.style.height = "".concat(this.height, "px"); | ||
this.div.setAttribute('style', "cursor: 'pointer'; position: 'absolute'; top: ".concat(pos !== null ? "".concat(pos.y, "px") : '0', "; left: ").concat(pos !== null ? "".concat(pos.x, "px") : '0', "; width: ").concat(this.width, "px; height: ").concat(this.height, "px; ")); | ||
var img = document.createElement('img'); | ||
@@ -199,5 +188,3 @@ img.alt = divTitle; | ||
img.height = this.height; | ||
img.style.position = 'absolute'; | ||
img.style.top = "".concat(spriteV, "px"); | ||
img.style.left = "".concat(spriteH, "px"); | ||
img.setAttribute('style', "position: absolute; top: ".concat(spriteV, "px; left: ").concat(spriteH, "px")); | ||
if (!this.cluster.getClusterer().enableRetinaIcons) { | ||
@@ -207,15 +194,7 @@ img.style.clip = "rect(-".concat(spriteV, "px, -").concat(spriteH + this.width, "px, -").concat(spriteV + this.height, ", -").concat(spriteH, ")"); | ||
var textElm = document.createElement('div'); | ||
textElm.style.position = 'absolute'; | ||
textElm.style.top = "".concat(this.anchorText[0], "px"); | ||
textElm.style.left = "".concat(this.anchorText[1], "px"); | ||
textElm.style.color = this.textColor; | ||
textElm.style.fontSize = "".concat(this.textSize, "px"); | ||
textElm.style.fontFamily = this.fontFamily; | ||
textElm.style.fontWeight = this.fontWeight; | ||
textElm.style.fontStyle = this.fontStyle; | ||
textElm.style.textDecoration = this.textDecoration; | ||
textElm.style.textAlign = 'center'; | ||
textElm.style.width = "".concat(this.width, "px"); | ||
textElm.style.lineHeight = "".concat(this.height, "px"); | ||
textElm.innerText = "".concat((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text); | ||
textElm.setAttribute('style', "position: absolute; top: ".concat(this.anchorText[0], "px; left: ").concat(this.anchorText[1], "px; color: ").concat(this.textColor, "; font-size: ").concat(this.textSize, "px; font-family: ").concat(this.fontFamily, "; font-weight: ").concat(this.fontWeight, "; fontStyle: ").concat(this.fontStyle, "; text-decoration: ").concat(this.textDecoration, "; text-align: center; width: ").concat(this.width, "px; line-height: ").concat(this.height, "px")); | ||
if ((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text) | ||
textElm.innerText = "".concat((_b = this.sums) === null || _b === void 0 ? void 0 : _b.text); | ||
if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.html) | ||
textElm.innerHTML = "".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.html); | ||
this.div.innerHTML = ''; | ||
@@ -972,5 +951,3 @@ this.div.appendChild(img); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=umd.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).markerClusterer={})}(this,(function(t){"use strict";var e=function(){function t(e,i){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=i,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(t){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var e=this.cluster.getClusterer();if(google.maps.event.trigger(e,"click",this.cluster),google.maps.event.trigger(e,"clusterclick",this.cluster),e.getZoomOnClick()){var i=e.getMaxZoom(),s=this.cluster.getBounds(),n=e.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var n=t.getZoom()||0;null!==i&&n>i&&t.setZoom(i+1)}}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var t;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),null===(t=this.getPanes())||void 0===t||t.overlayMouseTarget.appendChild(this.div);var e=this.getMap();null!==e&&(this.boundsChangedListener=google.maps.event.addListener(e,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),null!==this.boundsChangedListener&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),null!==this.timeOut&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&null!==this.div&&this.center){var t=this.getPosFromLatLng(this.center);this.div.style.top=null!==t?"".concat(t.y,"px"):"0",this.div.style.left=null!==t?"".concat(t.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var t;if(this.div&&this.center){var e="",i=this.backgroundPosition.split(" "),s=parseInt(i[0].replace(/^\s+|\s+$/g,""),10),n=parseInt(i[1].replace(/^\s+|\s+$/g,""),10),r=this.getPosFromLatLng(this.center);e=null===this.sums||void 0===this.sums.title||""===this.sums.title?this.cluster.getClusterer().getTitle():this.sums.title,this.div.className=this.className,this.div.style.cursor="pointer",this.div.style.position="absolute",this.div.style.top=null!==r?"".concat(r.y,"px"):"0",this.div.style.left=null!==r?"".concat(r.x,"px"):"0",this.div.style.width="".concat(this.width,"px"),this.div.style.height="".concat(this.height,"px");var o=document.createElement("img");o.alt=e,o.src=this.url,o.width=this.width,o.height=this.height,o.style.position="absolute",o.style.top="".concat(n,"px"),o.style.left="".concat(s,"px"),this.cluster.getClusterer().enableRetinaIcons||(o.style.clip="rect(-".concat(n,"px, -").concat(s+this.width,"px, -").concat(n+this.height,", -").concat(s,")"));var h=document.createElement("div");h.style.position="absolute",h.style.top="".concat(this.anchorText[0],"px"),h.style.left="".concat(this.anchorText[1],"px"),h.style.color=this.textColor,h.style.fontSize="".concat(this.textSize,"px"),h.style.fontFamily=this.fontFamily,h.style.fontWeight=this.fontWeight,h.style.fontStyle=this.fontStyle,h.style.textDecoration=this.textDecoration,h.style.textAlign="center",h.style.width="".concat(this.width,"px"),h.style.lineHeight="".concat(this.height,"px"),h.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(h),this.div.title=e,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(t){this.sums=t;var e=this.cluster.getClusterer().getStyles(),i=e[Math.min(e.length-1,Math.max(0,t.index-1))];this.url=i.url,this.height=i.height,this.width=i.width,i.className&&(this.className="".concat(this.clusterClassName," ").concat(i.className)),this.anchorText=i.anchorText||[0,0],this.anchorIcon=i.anchorIcon||[this.height/2,this.width/2],this.textColor=i.textColor||"black",this.textSize=i.textSize||11,this.textDecoration=i.textDecoration||"none",this.fontWeight=i.fontWeight||"bold",this.fontStyle=i.fontStyle||"normal",this.fontFamily=i.fontFamily||"Arial,sans-serif",this.backgroundPosition=i.backgroundPosition||"0 0"},t.prototype.setCenter=function(t){this.center=t},t.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},t}(),i=function(){function t(t){this.markerClusterer=t,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new e(this,this.markerClusterer.getStyles()),this.getSize=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return t.prototype.getSize=function(){return this.markers.length},t.prototype.getMarkers=function(){return this.markers},t.prototype.getCenter=function(){return this.center},t.prototype.getMap=function(){return this.map},t.prototype.getClusterer=function(){return this.markerClusterer},t.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center,this.center),e=this.getMarkers(),i=0;i<e.length;i++){var s=e[i].getPosition();s&&t.extend(s)}return t},t.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},t.prototype.addMarker=function(t){var e,i;if(this.isMarkerAlreadyAdded(t))return!1;if(this.center){if(this.averageCenter&&(i=t.getPosition())){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+i.lat())/s,(this.center.lng()*(s-1)+i.lng())/s),this.calculateBounds()}}else(i=t.getPosition())&&(this.center=i,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var n=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(n<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(n===this.minClusterSize)for(var h=0;h<n;h++)this.markers[h].setMap(null);else t.setMap(null);return!0},t.prototype.isMarkerInClusterBounds=function(t){if(null!==this.bounds){var e=t.getPosition();if(e)return this.bounds.contains(e)}return!1},t.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},t.prototype.updateIcon=function(){var t,e=this.markers.length,i=this.markerClusterer.getMaxZoom(),s=null===(t=this.map)||void 0===t?void 0:t.getZoom();null!==i&&void 0!==s&&s>i||e<this.minClusterSize?this.clusterIcon.hide():(this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show())},t.prototype.isMarkerAlreadyAdded=function(t){if(this.markers.includes)return this.markers.includes(t);for(var e=0;e<this.markers.length;e++)if(t===this.markers[e])return!0;return!1},t}();function s(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}}var n=[53,56,66,78,90],r=function(){function t(e,i,r){void 0===i&&(i=[]),void 0===r&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createClusters=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.extend=this.extend.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,void 0!==r.zoomOnClick&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,void 0!==r.averageCenter&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,void 0!==r.ignoreHidden&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=r.imageExtension||"png",this.imageSizes=r.imageSizes||n,this.calculator=r.calculator||s,this.batchSize=r.batchSize||2e3,this.batchSizeIE=r.batchSizeIE||500,this.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(i,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var t,e;this.resetViewport(!1),(null===(t=this.getMap())||void 0===t?void 0:t.getZoom())!==(this.get("minZoom")||0)&&(null===(e=this.getMap())||void 0===e?void 0:e.getZoom())!==this.get("maxZoom")||google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var t=this.getMap();this.activeMap=t,this.ready=!0,this.repaint(),null!==t&&(this.listeners=[google.maps.event.addListener(t,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(t,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var t=0;t<this.markers.length;t++)this.markers[t].getMap()!==this.activeMap&&this.markers[t].setMap(this.activeMap);for(t=0;t<this.clusters.length;t++)this.clusters[t].remove();this.clusters=[];for(t=0;t<this.listeners.length;t++)google.maps.event.removeListener(this.listeners[t]);this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:"".concat(this.imagePath+(t+1),".").concat(this.imageExtension),height:this.imageSizes[t],width:this.imageSizes[t]})},t.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0;i<t.length;i++){var s=t[i].getPosition();s&&e.extend(s)}var n=this.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(e)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(t){this.gridSize=t},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(t){this.maxZoom=t},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(t){this.styles=t},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(t){this.title=t},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(t){this.averageCenter=t},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(t){this.imageExtension=t},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(t){this.imagePath=t},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(t){this.imageSizes=t},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(t){this.calculator=t},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(t){this.clusterClass=t},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},t.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},t.prototype.pushMarkerTo=function(t){var e=this;t.getDraggable()&&google.maps.event.addListener(t,"dragend",(function(){e.ready&&(t.isAdded=!1,e.repaint())})),t.isAdded=!1,this.markers.push(t)},t.prototype.removeMarker_=function(t){var e=-1;if(this.markers.indexOf)e=this.markers.indexOf(t);else for(var i=0;i<this.markers.length;i++)if(t===this.markers[i]){e=i;break}return-1!==e&&(t.setMap(null),this.markers.splice(e,1),!0)},t.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},t.prototype.removeMarkers=function(t,e){for(var i=!1,s=0;s<t.length;s++)i=i||this.removeMarker_(t[s]);return!e&&i&&this.repaint(),i},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},t.prototype.repaint=function(){var t=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout((function(){for(var e=0;e<t.length;e++)t[e].remove()}),0)},t.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()));null!==i&&(i.x+=this.gridSize,i.y-=this.gridSize);var s=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()));if(null!==s&&(s.x-=this.gridSize,s.y+=this.gridSize),null!==i){var n=e.fromDivPixelToLatLng(i);null!==n&&t.extend(n)}if(null!==s){var r=e.fromDivPixelToLatLng(s);null!==r&&t.extend(r)}return t},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(t){for(var e=0;e<this.clusters.length;e++)this.clusters[e].remove();this.clusters=[];for(e=0;e<this.markers.length;e++){var i=this.markers[e];i.isAdded=!1,t&&i.setMap(null)}},t.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,n=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371},t.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},t.prototype.addToClosestCluster=function(t){for(var e,s=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(e=this.clusters[r]).getCenter(),h=t.getPosition();if(o&&h){var a=this.distanceBetweenPoints(o,h);a<s&&(s=a,n=e)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((e=new i(this)).addMarker(t),this.clusters.push(e))},t.prototype.createClusters=function(t){var e=this;if(this.ready){0===t&&(google.maps.event.trigger(this,"clusteringbegin",this),null!==this.timerRefStatic&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var i=this.getMap(),s=(null!==i&&"getBounds"in i?i.getBounds():null),n=((null==i?void 0:i.getZoom())||0)>3?new google.maps.LatLngBounds(null==s?void 0:s.getSouthWest(),null==s?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),r=this.getExtendedBounds(n),o=Math.min(t+this.batchSize,this.markers.length),h=t;h<o;h++){var a=this.markers[h];!a.isAdded&&this.isMarkerInBounds(a,r)&&(!this.ignoreHidden||this.ignoreHidden&&a.getVisible())&&this.addToClosestCluster(a)}if(o<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(o)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(h=0;h<this.clusters.length;h++)this.clusters[h].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])},t}();t.Cluster=i,t.ClusterIcon=e,t.Clusterer=r,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).markerClusterer={})}(this,(function(t){"use strict";var e=function(){function t(e,i){e.getClusterer().extend(t,google.maps.OverlayView),this.cluster=e,this.clusterClassName=this.cluster.getClusterer().getClusterClass(),this.className=this.clusterClassName,this.styles=i,this.center=void 0,this.div=null,this.sums=null,this.visible=!1,this.boundsChangedListener=null,this.url="",this.height=0,this.width=0,this.anchorText=[0,0],this.anchorIcon=[0,0],this.textColor="black",this.textSize=11,this.textDecoration="none",this.fontWeight="bold",this.fontStyle="normal",this.fontFamily="Arial,sans-serif",this.backgroundPosition="0 0",this.cMouseDownInCluster=null,this.cDraggingMapByCluster=null,this.timeOut=null,this.setMap(e.getMap()),this.onBoundsChanged=this.onBoundsChanged.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onClick=this.onClick.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onAdd=this.onAdd.bind(this),this.onRemove=this.onRemove.bind(this),this.draw=this.draw.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.useStyle=this.useStyle.bind(this),this.setCenter=this.setCenter.bind(this),this.getPosFromLatLng=this.getPosFromLatLng.bind(this)}return t.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},t.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},t.prototype.onClick=function(t){if(this.cMouseDownInCluster=!1,!this.cDraggingMapByCluster){var e=this.cluster.getClusterer();if(google.maps.event.trigger(e,"click",this.cluster),google.maps.event.trigger(e,"clusterclick",this.cluster),e.getZoomOnClick()){var i=e.getMaxZoom(),s=this.cluster.getBounds(),n=e.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var n=t.getZoom()||0;null!==i&&n>i&&t.setZoom(i+1)}}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},t.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},t.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},t.prototype.onAdd=function(){var t;this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),null===(t=this.getPanes())||void 0===t||t.overlayMouseTarget.appendChild(this.div);var e=this.getMap();null!==e&&(this.boundsChangedListener=google.maps.event.addListener(e,"bounds_changed",this.onBoundsChanged),this.div.addEventListener("mousedown",this.onMouseDown),this.div.addEventListener("click",this.onClick),this.div.addEventListener("mouseover",this.onMouseOver),this.div.addEventListener("mouseout",this.onMouseOut))},t.prototype.onRemove=function(){this.div&&this.div.parentNode&&(this.hide(),null!==this.boundsChangedListener&&google.maps.event.removeListener(this.boundsChangedListener),this.div.removeEventListener("mousedown",this.onMouseDown),this.div.removeEventListener("click",this.onClick),this.div.removeEventListener("mouseover",this.onMouseOver),this.div.removeEventListener("mouseout",this.onMouseOut),this.div.parentNode.removeChild(this.div),null!==this.timeOut&&(window.clearTimeout(this.timeOut),this.timeOut=null),this.div=null)},t.prototype.draw=function(){if(this.visible&&null!==this.div&&this.center){var t=this.getPosFromLatLng(this.center);this.div.style.top=null!==t?"".concat(t.y,"px"):"0",this.div.style.left=null!==t?"".concat(t.x,"px"):"0"}},t.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},t.prototype.show=function(){var t,e,i,s;if(this.div&&this.center){var n=null===this.sums||void 0===this.sums.title||""===this.sums.title?this.cluster.getClusterer().getTitle():this.sums.title,r=this.backgroundPosition.split(" "),o=parseInt(r[0].replace(/^\s+|\s+$/g,""),10),h=parseInt(r[1].replace(/^\s+|\s+$/g,""),10),a=this.getPosFromLatLng(this.center);this.div.className=this.className,this.div.setAttribute("style","cursor: 'pointer'; position: 'absolute'; top: ".concat(null!==a?"".concat(a.y,"px"):"0","; left: ").concat(null!==a?"".concat(a.x,"px"):"0","; width: ").concat(this.width,"px; height: ").concat(this.height,"px; "));var l=document.createElement("img");l.alt=n,l.src=this.url,l.width=this.width,l.height=this.height,l.setAttribute("style","position: absolute; top: ".concat(h,"px; left: ").concat(o,"px")),this.cluster.getClusterer().enableRetinaIcons||(l.style.clip="rect(-".concat(h,"px, -").concat(o+this.width,"px, -").concat(h+this.height,", -").concat(o,")"));var u=document.createElement("div");u.setAttribute("style","position: absolute; top: ".concat(this.anchorText[0],"px; left: ").concat(this.anchorText[1],"px; color: ").concat(this.textColor,"; font-size: ").concat(this.textSize,"px; font-family: ").concat(this.fontFamily,"; font-weight: ").concat(this.fontWeight,"; fontStyle: ").concat(this.fontStyle,"; text-decoration: ").concat(this.textDecoration,"; text-align: center; width: ").concat(this.width,"px; line-height: ").concat(this.height,"px")),(null===(t=this.sums)||void 0===t?void 0:t.text)&&(u.innerText="".concat(null===(e=this.sums)||void 0===e?void 0:e.text)),(null===(i=this.sums)||void 0===i?void 0:i.html)&&(u.innerHTML="".concat(null===(s=this.sums)||void 0===s?void 0:s.html)),this.div.innerHTML="",this.div.appendChild(l),this.div.appendChild(u),this.div.title=n,this.div.style.display=""}this.visible=!0},t.prototype.useStyle=function(t){this.sums=t;var e=this.cluster.getClusterer().getStyles(),i=e[Math.min(e.length-1,Math.max(0,t.index-1))];this.url=i.url,this.height=i.height,this.width=i.width,i.className&&(this.className="".concat(this.clusterClassName," ").concat(i.className)),this.anchorText=i.anchorText||[0,0],this.anchorIcon=i.anchorIcon||[this.height/2,this.width/2],this.textColor=i.textColor||"black",this.textSize=i.textSize||11,this.textDecoration=i.textDecoration||"none",this.fontWeight=i.fontWeight||"bold",this.fontStyle=i.fontStyle||"normal",this.fontFamily=i.fontFamily||"Arial,sans-serif",this.backgroundPosition=i.backgroundPosition||"0 0"},t.prototype.setCenter=function(t){this.center=t},t.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},t}(),i=function(){function t(t){this.markerClusterer=t,this.map=this.markerClusterer.getMap(),this.gridSize=this.markerClusterer.getGridSize(),this.minClusterSize=this.markerClusterer.getMinimumClusterSize(),this.averageCenter=this.markerClusterer.getAverageCenter(),this.markers=[],this.center=void 0,this.bounds=null,this.clusterIcon=new e(this,this.markerClusterer.getStyles()),this.getSize=this.getSize.bind(this),this.getMarkers=this.getMarkers.bind(this),this.getCenter=this.getCenter.bind(this),this.getMap=this.getMap.bind(this),this.getClusterer=this.getClusterer.bind(this),this.getBounds=this.getBounds.bind(this),this.remove=this.remove.bind(this),this.addMarker=this.addMarker.bind(this),this.isMarkerInClusterBounds=this.isMarkerInClusterBounds.bind(this),this.calculateBounds=this.calculateBounds.bind(this),this.updateIcon=this.updateIcon.bind(this),this.isMarkerAlreadyAdded=this.isMarkerAlreadyAdded.bind(this)}return t.prototype.getSize=function(){return this.markers.length},t.prototype.getMarkers=function(){return this.markers},t.prototype.getCenter=function(){return this.center},t.prototype.getMap=function(){return this.map},t.prototype.getClusterer=function(){return this.markerClusterer},t.prototype.getBounds=function(){for(var t=new google.maps.LatLngBounds(this.center,this.center),e=this.getMarkers(),i=0;i<e.length;i++){var s=e[i].getPosition();s&&t.extend(s)}return t},t.prototype.remove=function(){this.clusterIcon.setMap(null),this.markers=[],delete this.markers},t.prototype.addMarker=function(t){var e,i;if(this.isMarkerAlreadyAdded(t))return!1;if(this.center){if(this.averageCenter&&(i=t.getPosition())){var s=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(s-1)+i.lat())/s,(this.center.lng()*(s-1)+i.lng())/s),this.calculateBounds()}}else(i=t.getPosition())&&(this.center=i,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var n=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(n<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(n===this.minClusterSize)for(var h=0;h<n;h++)this.markers[h].setMap(null);else t.setMap(null);return!0},t.prototype.isMarkerInClusterBounds=function(t){if(null!==this.bounds){var e=t.getPosition();if(e)return this.bounds.contains(e)}return!1},t.prototype.calculateBounds=function(){this.bounds=this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center,this.center))},t.prototype.updateIcon=function(){var t,e=this.markers.length,i=this.markerClusterer.getMaxZoom(),s=null===(t=this.map)||void 0===t?void 0:t.getZoom();null!==i&&void 0!==s&&s>i||e<this.minClusterSize?this.clusterIcon.hide():(this.center&&this.clusterIcon.setCenter(this.center),this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers,this.markerClusterer.getStyles().length)),this.clusterIcon.show())},t.prototype.isMarkerAlreadyAdded=function(t){if(this.markers.includes)return this.markers.includes(t);for(var e=0;e<this.markers.length;e++)if(t===this.markers[e])return!0;return!1},t}();function s(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}}var n=[53,56,66,78,90],r=function(){function t(e,i,r){void 0===i&&(i=[]),void 0===r&&(r={}),this.getMinimumClusterSize=this.getMinimumClusterSize.bind(this),this.setMinimumClusterSize=this.setMinimumClusterSize.bind(this),this.getEnableRetinaIcons=this.getEnableRetinaIcons.bind(this),this.setEnableRetinaIcons=this.setEnableRetinaIcons.bind(this),this.addToClosestCluster=this.addToClosestCluster.bind(this),this.getImageExtension=this.getImageExtension.bind(this),this.setImageExtension=this.setImageExtension.bind(this),this.getExtendedBounds=this.getExtendedBounds.bind(this),this.getAverageCenter=this.getAverageCenter.bind(this),this.setAverageCenter=this.setAverageCenter.bind(this),this.getTotalClusters=this.getTotalClusters.bind(this),this.fitMapToMarkers=this.fitMapToMarkers.bind(this),this.getIgnoreHidden=this.getIgnoreHidden.bind(this),this.setIgnoreHidden=this.setIgnoreHidden.bind(this),this.getClusterClass=this.getClusterClass.bind(this),this.setClusterClass=this.setClusterClass.bind(this),this.getTotalMarkers=this.getTotalMarkers.bind(this),this.getZoomOnClick=this.getZoomOnClick.bind(this),this.setZoomOnClick=this.setZoomOnClick.bind(this),this.getBatchSizeIE=this.getBatchSizeIE.bind(this),this.setBatchSizeIE=this.setBatchSizeIE.bind(this),this.createClusters=this.createClusters.bind(this),this.onZoomChanged=this.onZoomChanged.bind(this),this.getImageSizes=this.getImageSizes.bind(this),this.setImageSizes=this.setImageSizes.bind(this),this.getCalculator=this.getCalculator.bind(this),this.setCalculator=this.setCalculator.bind(this),this.removeMarkers=this.removeMarkers.bind(this),this.resetViewport=this.resetViewport.bind(this),this.getImagePath=this.getImagePath.bind(this),this.setImagePath=this.setImagePath.bind(this),this.pushMarkerTo=this.pushMarkerTo.bind(this),this.removeMarker=this.removeMarker.bind(this),this.clearMarkers=this.clearMarkers.bind(this),this.setupStyles=this.setupStyles.bind(this),this.getGridSize=this.getGridSize.bind(this),this.setGridSize=this.setGridSize.bind(this),this.getClusters=this.getClusters.bind(this),this.getMaxZoom=this.getMaxZoom.bind(this),this.setMaxZoom=this.setMaxZoom.bind(this),this.getMarkers=this.getMarkers.bind(this),this.addMarkers=this.addMarkers.bind(this),this.getStyles=this.getStyles.bind(this),this.setStyles=this.setStyles.bind(this),this.addMarker=this.addMarker.bind(this),this.onRemove=this.onRemove.bind(this),this.getTitle=this.getTitle.bind(this),this.setTitle=this.setTitle.bind(this),this.repaint=this.repaint.bind(this),this.onIdle=this.onIdle.bind(this),this.redraw=this.redraw.bind(this),this.extend=this.extend.bind(this),this.onAdd=this.onAdd.bind(this),this.draw=this.draw.bind(this),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=r.gridSize||60,this.minClusterSize=r.minimumClusterSize||2,this.maxZoom=r.maxZoom||null,this.styles=r.styles||[],this.title=r.title||"",this.zoomOnClick=!0,void 0!==r.zoomOnClick&&(this.zoomOnClick=r.zoomOnClick),this.averageCenter=!1,void 0!==r.averageCenter&&(this.averageCenter=r.averageCenter),this.ignoreHidden=!1,void 0!==r.ignoreHidden&&(this.ignoreHidden=r.ignoreHidden),this.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(this.enableRetinaIcons=r.enableRetinaIcons),this.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=r.imageExtension||"png",this.imageSizes=r.imageSizes||n,this.calculator=r.calculator||s,this.batchSize=r.batchSize||2e3,this.batchSizeIE=r.batchSizeIE||500,this.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(i,!0),this.setMap(e)}return t.prototype.onZoomChanged=function(){var t,e;this.resetViewport(!1),(null===(t=this.getMap())||void 0===t?void 0:t.getZoom())!==(this.get("minZoom")||0)&&(null===(e=this.getMap())||void 0===e?void 0:e.getZoom())!==this.get("maxZoom")||google.maps.event.trigger(this,"idle")},t.prototype.onIdle=function(){this.redraw()},t.prototype.onAdd=function(){var t=this.getMap();this.activeMap=t,this.ready=!0,this.repaint(),null!==t&&(this.listeners=[google.maps.event.addListener(t,"zoom_changed",this.onZoomChanged),google.maps.event.addListener(t,"idle",this.onIdle)])},t.prototype.onRemove=function(){for(var t=0;t<this.markers.length;t++)this.markers[t].getMap()!==this.activeMap&&this.markers[t].setMap(this.activeMap);for(t=0;t<this.clusters.length;t++)this.clusters[t].remove();this.clusters=[];for(t=0;t<this.listeners.length;t++)google.maps.event.removeListener(this.listeners[t]);this.listeners=[],this.activeMap=null,this.ready=!1},t.prototype.draw=function(){},t.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:"".concat(this.imagePath+(t+1),".").concat(this.imageExtension),height:this.imageSizes[t],width:this.imageSizes[t]})},t.prototype.fitMapToMarkers=function(){for(var t=this.getMarkers(),e=new google.maps.LatLngBounds,i=0;i<t.length;i++){var s=t[i].getPosition();s&&e.extend(s)}var n=this.getMap();null!==n&&"fitBounds"in n&&n.fitBounds(e)},t.prototype.getGridSize=function(){return this.gridSize},t.prototype.setGridSize=function(t){this.gridSize=t},t.prototype.getMinimumClusterSize=function(){return this.minClusterSize},t.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},t.prototype.getMaxZoom=function(){return this.maxZoom},t.prototype.setMaxZoom=function(t){this.maxZoom=t},t.prototype.getStyles=function(){return this.styles},t.prototype.setStyles=function(t){this.styles=t},t.prototype.getTitle=function(){return this.title},t.prototype.setTitle=function(t){this.title=t},t.prototype.getZoomOnClick=function(){return this.zoomOnClick},t.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},t.prototype.getAverageCenter=function(){return this.averageCenter},t.prototype.setAverageCenter=function(t){this.averageCenter=t},t.prototype.getIgnoreHidden=function(){return this.ignoreHidden},t.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},t.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},t.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},t.prototype.getImageExtension=function(){return this.imageExtension},t.prototype.setImageExtension=function(t){this.imageExtension=t},t.prototype.getImagePath=function(){return this.imagePath},t.prototype.setImagePath=function(t){this.imagePath=t},t.prototype.getImageSizes=function(){return this.imageSizes},t.prototype.setImageSizes=function(t){this.imageSizes=t},t.prototype.getCalculator=function(){return this.calculator},t.prototype.setCalculator=function(t){this.calculator=t},t.prototype.getBatchSizeIE=function(){return this.batchSizeIE},t.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},t.prototype.getClusterClass=function(){return this.clusterClass},t.prototype.setClusterClass=function(t){this.clusterClass=t},t.prototype.getMarkers=function(){return this.markers},t.prototype.getTotalMarkers=function(){return this.markers.length},t.prototype.getClusters=function(){return this.clusters},t.prototype.getTotalClusters=function(){return this.clusters.length},t.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},t.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},t.prototype.pushMarkerTo=function(t){var e=this;t.getDraggable()&&google.maps.event.addListener(t,"dragend",(function(){e.ready&&(t.isAdded=!1,e.repaint())})),t.isAdded=!1,this.markers.push(t)},t.prototype.removeMarker_=function(t){var e=-1;if(this.markers.indexOf)e=this.markers.indexOf(t);else for(var i=0;i<this.markers.length;i++)if(t===this.markers[i]){e=i;break}return-1!==e&&(t.setMap(null),this.markers.splice(e,1),!0)},t.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},t.prototype.removeMarkers=function(t,e){for(var i=!1,s=0;s<t.length;s++)i=i||this.removeMarker_(t[s]);return!e&&i&&this.repaint(),i},t.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},t.prototype.repaint=function(){var t=this.clusters.slice();this.clusters=[],this.resetViewport(!1),this.redraw(),setTimeout((function(){for(var e=0;e<t.length;e++)t[e].remove()}),0)},t.prototype.getExtendedBounds=function(t){var e=this.getProjection(),i=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()));null!==i&&(i.x+=this.gridSize,i.y-=this.gridSize);var s=e.fromLatLngToDivPixel(new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()));if(null!==s&&(s.x-=this.gridSize,s.y+=this.gridSize),null!==i){var n=e.fromDivPixelToLatLng(i);null!==n&&t.extend(n)}if(null!==s){var r=e.fromDivPixelToLatLng(s);null!==r&&t.extend(r)}return t},t.prototype.redraw=function(){this.createClusters(0)},t.prototype.resetViewport=function(t){for(var e=0;e<this.clusters.length;e++)this.clusters[e].remove();this.clusters=[];for(e=0;e<this.markers.length;e++){var i=this.markers[e];i.isAdded=!1,t&&i.setMap(null)}},t.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,n=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371},t.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},t.prototype.addToClosestCluster=function(t){for(var e,s=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(e=this.clusters[r]).getCenter(),h=t.getPosition();if(o&&h){var a=this.distanceBetweenPoints(o,h);a<s&&(s=a,n=e)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((e=new i(this)).addMarker(t),this.clusters.push(e))},t.prototype.createClusters=function(t){var e=this;if(this.ready){0===t&&(google.maps.event.trigger(this,"clusteringbegin",this),null!==this.timerRefStatic&&(window.clearTimeout(this.timerRefStatic),delete this.timerRefStatic));for(var i=this.getMap(),s=(null!==i&&"getBounds"in i?i.getBounds():null),n=((null==i?void 0:i.getZoom())||0)>3?new google.maps.LatLngBounds(null==s?void 0:s.getSouthWest(),null==s?void 0:s.getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625)),r=this.getExtendedBounds(n),o=Math.min(t+this.batchSize,this.markers.length),h=t;h<o;h++){var a=this.markers[h];!a.isAdded&&this.isMarkerInBounds(a,r)&&(!this.ignoreHidden||this.ignoreHidden&&a.getVisible())&&this.addToClosestCluster(a)}if(o<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(o)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(h=0;h<this.clusters.length;h++)this.clusters[h].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])},t}();t.Cluster=i,t.ClusterIcon=e,t.Clusterer=r})); | ||
//# sourceMappingURL=umd.min.js.map |
{ | ||
"name": "@react-google-maps/marker-clusterer", | ||
"sideEffects": false, | ||
"version": "2.11.8", | ||
"version": "2.14.0", | ||
"description": "Marker Clusterer for React.js Google Maps API", | ||
@@ -56,12 +56,12 @@ "license": "MIT", | ||
"@getify/eslint-plugin-proper-arrows": "11.0.3", | ||
"@rollup/plugin-commonjs": "22.0.0", | ||
"@rollup/plugin-node-resolve": "13.3.0", | ||
"@rollup/plugin-typescript": "8.3.2", | ||
"@rollup/plugin-commonjs": "23.0.2", | ||
"@rollup/plugin-node-resolve": "15.0.1", | ||
"@rollup/plugin-typescript": "9.0.2", | ||
"@types/babel-types": "7.0.11", | ||
"@types/google.maps": "3.49.0", | ||
"jest": "28.1.0", | ||
"jest-cli": "28.1.0", | ||
"@types/google.maps": "3.50.5", | ||
"jest": "29.2.2", | ||
"jest-cli": "29.2.2", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.74.1", | ||
"rollup-plugin-dts": "4.2.1", | ||
"rollup": "3.2.5", | ||
"rollup-plugin-dts": "5.0.0", | ||
"rollup-plugin-terser": "7.0.2" | ||
@@ -68,0 +68,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
656790
26
4667