@react-google-maps/marker-clusterer
Advanced tools
Comparing version 2.11.2 to 2.11.3
101
dist/cjs.js
@@ -5,33 +5,2 @@ 'use strict'; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var ClusterIcon = /** @class */ (function () { | ||
@@ -413,2 +382,3 @@ function ClusterIcon(cluster, styles) { | ||
/* global google */ | ||
/** | ||
@@ -434,51 +404,48 @@ * Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers | ||
var CLUSTERER_CLASS = 'cluster'; | ||
var Clusterer = /** @class */ (function (_super) { | ||
__extends(Clusterer, _super); | ||
var Clusterer = /** @class */ (function () { | ||
function Clusterer(map, optMarkers, optOptions) { | ||
if (optMarkers === void 0) { optMarkers = []; } | ||
if (optOptions === void 0) { optOptions = {}; } | ||
var _this = _super.call(this) || this; | ||
_this.extend(Clusterer, google.maps.OverlayView); | ||
_this.markers = []; | ||
_this.clusters = []; | ||
_this.listeners = []; | ||
_this.activeMap = null; | ||
_this.ready = false; | ||
_this.gridSize = optOptions.gridSize || 60; | ||
_this.minClusterSize = optOptions.minimumClusterSize || 2; | ||
_this.maxZoom = optOptions.maxZoom || null; | ||
_this.styles = optOptions.styles || []; | ||
_this.title = optOptions.title || ''; | ||
_this.zoomOnClick = true; | ||
this.extend(Clusterer, google.maps.OverlayView); | ||
this.markers = []; | ||
this.clusters = []; | ||
this.listeners = []; | ||
this.activeMap = null; | ||
this.ready = false; | ||
this.gridSize = optOptions.gridSize || 60; | ||
this.minClusterSize = optOptions.minimumClusterSize || 2; | ||
this.maxZoom = optOptions.maxZoom || null; | ||
this.styles = optOptions.styles || []; | ||
this.title = optOptions.title || ''; | ||
this.zoomOnClick = true; | ||
if (optOptions.zoomOnClick !== undefined) { | ||
_this.zoomOnClick = optOptions.zoomOnClick; | ||
this.zoomOnClick = optOptions.zoomOnClick; | ||
} | ||
_this.averageCenter = false; | ||
this.averageCenter = false; | ||
if (optOptions.averageCenter !== undefined) { | ||
_this.averageCenter = optOptions.averageCenter; | ||
this.averageCenter = optOptions.averageCenter; | ||
} | ||
_this.ignoreHidden = false; | ||
this.ignoreHidden = false; | ||
if (optOptions.ignoreHidden !== undefined) { | ||
_this.ignoreHidden = optOptions.ignoreHidden; | ||
this.ignoreHidden = optOptions.ignoreHidden; | ||
} | ||
_this.enableRetinaIcons = false; | ||
this.enableRetinaIcons = false; | ||
if (optOptions.enableRetinaIcons !== undefined) { | ||
_this.enableRetinaIcons = optOptions.enableRetinaIcons; | ||
this.enableRetinaIcons = optOptions.enableRetinaIcons; | ||
} | ||
_this.imagePath = optOptions.imagePath || IMAGE_PATH; | ||
_this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION; | ||
_this.imageSizes = optOptions.imageSizes || IMAGE_SIZES; | ||
_this.calculator = optOptions.calculator || CALCULATOR; | ||
_this.batchSize = optOptions.batchSize || BATCH_SIZE; | ||
_this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE; | ||
_this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS; | ||
this.imagePath = optOptions.imagePath || IMAGE_PATH; | ||
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION; | ||
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES; | ||
this.calculator = optOptions.calculator || CALCULATOR; | ||
this.batchSize = optOptions.batchSize || BATCH_SIZE; | ||
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE; | ||
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS; | ||
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) { | ||
// Try to avoid IE timeout when processing a huge number of markers: | ||
_this.batchSize = _this.batchSizeIE; | ||
this.batchSize = this.batchSizeIE; | ||
} | ||
_this.timerRefStatic = null; | ||
_this.setupStyles(); | ||
_this.addMarkers(optMarkers, true); | ||
_this.setMap(map); // Note: this causes onAdd to be called | ||
return _this; | ||
this.timerRefStatic = null; | ||
this.setupStyles(); | ||
this.addMarkers(optMarkers, true); | ||
this.setMap(map); // Note: this causes onAdd to be called | ||
} | ||
@@ -914,3 +881,3 @@ Clusterer.prototype.onZoomChanged = function () { | ||
return Clusterer; | ||
}(google.maps.OverlayView)); | ||
}()); | ||
@@ -917,0 +884,0 @@ exports.Cluster = Cluster; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};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())}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(),r=e.getMap();null!==r&&"fitBounds"in r&&r.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var r=t.getZoom()||0;null!==i&&r>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),r=parseInt(i[1].replace(/^\s+|\s+$/g,""),10),o=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.style.cursor="pointer",this.div.style.position="absolute",this.div.style.top=null!==o?"".concat(o.y,"px"):"0",this.div.style.left=null!==o?"".concat(o.x,"px"):"0",this.div.style.width="".concat(this.width,"px"),this.div.style.height="".concat(this.height,"px");var n=document.createElement("img");n.alt=e,n.src=this.url,n.style.position="absolute",n.style.top="".concat(r,"px"),n.style.left="".concat(s,"px"),this.cluster.getClusterer().enableRetinaIcons||(n.style.clip="rect(-".concat(r,"px, -").concat(s+this.width,"px, -").concat(r+this.height,", -").concat(s,")"));var a=document.createElement("div");a.style.position="absolute",a.style.top="".concat(this.anchorText[0],"px"),a.style.left="".concat(this.anchorText[1],"px"),a.style.color=this.textColor,a.style.fontSize="".concat(this.textSize,"px"),a.style.fontFamily=this.fontFamily,a.style.fontWeight=this.fontWeight,a.style.fontStyle=this.fontStyle,a.style.textDecoration=this.textDecoration,a.style.textAlign="center",a.style.width="".concat(this.width,"px"),a.style.lineHeight="".concat(this.height,"px"),a.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(n),this.div.appendChild(a),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())}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 r=this.markers.length,o=this.markerClusterer.getMaxZoom(),n=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==o&&void 0!==n&&n>o)t.getMap()!==this.map&&t.setMap(this.map);else if(r<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(r===this.minClusterSize)for(var a=0;a<r;a++)this.markers[a].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}(),s=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},r=[53,56,66,78,90],o=function(e){function o(t,i,n){void 0===i&&(i=[]),void 0===n&&(n={});var a=e.call(this)||this;return a.extend(o,google.maps.OverlayView),a.markers=[],a.clusters=[],a.listeners=[],a.activeMap=null,a.ready=!1,a.gridSize=n.gridSize||60,a.minClusterSize=n.minimumClusterSize||2,a.maxZoom=n.maxZoom||null,a.styles=n.styles||[],a.title=n.title||"",a.zoomOnClick=!0,void 0!==n.zoomOnClick&&(a.zoomOnClick=n.zoomOnClick),a.averageCenter=!1,void 0!==n.averageCenter&&(a.averageCenter=n.averageCenter),a.ignoreHidden=!1,void 0!==n.ignoreHidden&&(a.ignoreHidden=n.ignoreHidden),a.enableRetinaIcons=!1,void 0!==n.enableRetinaIcons&&(a.enableRetinaIcons=n.enableRetinaIcons),a.imagePath=n.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",a.imageExtension=n.imageExtension||"png",a.imageSizes=n.imageSizes||r,a.calculator=n.calculator||s,a.batchSize=n.batchSize||2e3,a.batchSizeIE=n.batchSizeIE||500,a.clusterClass=n.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(a.batchSize=a.batchSizeIE),a.timerRefStatic=null,a.setupStyles(),a.addMarkers(i,!0),a.setMap(t),a}return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}(o,e),o.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")},o.prototype.onIdle=function(){this.redraw()},o.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)])},o.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},o.prototype.draw=function(){},o.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:this.imagePath+(t+1)+"."+this.imageExtension,height:this.imageSizes[t],width:this.imageSizes[t]})},o.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 r=this.getMap();null!==r&&"fitBounds"in r&&r.fitBounds(e)},o.prototype.getGridSize=function(){return this.gridSize},o.prototype.setGridSize=function(t){this.gridSize=t},o.prototype.getMinimumClusterSize=function(){return this.minClusterSize},o.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},o.prototype.getMaxZoom=function(){return this.maxZoom},o.prototype.setMaxZoom=function(t){this.maxZoom=t},o.prototype.getStyles=function(){return this.styles},o.prototype.setStyles=function(t){this.styles=t},o.prototype.getTitle=function(){return this.title},o.prototype.setTitle=function(t){this.title=t},o.prototype.getZoomOnClick=function(){return this.zoomOnClick},o.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},o.prototype.getAverageCenter=function(){return this.averageCenter},o.prototype.setAverageCenter=function(t){this.averageCenter=t},o.prototype.getIgnoreHidden=function(){return this.ignoreHidden},o.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},o.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},o.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},o.prototype.getImageExtension=function(){return this.imageExtension},o.prototype.setImageExtension=function(t){this.imageExtension=t},o.prototype.getImagePath=function(){return this.imagePath},o.prototype.setImagePath=function(t){this.imagePath=t},o.prototype.getImageSizes=function(){return this.imageSizes},o.prototype.setImageSizes=function(t){this.imageSizes=t},o.prototype.getCalculator=function(){return this.calculator},o.prototype.setCalculator=function(t){this.calculator=t},o.prototype.getBatchSizeIE=function(){return this.batchSizeIE},o.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},o.prototype.getClusterClass=function(){return this.clusterClass},o.prototype.setClusterClass=function(t){this.clusterClass=t},o.prototype.getMarkers=function(){return this.markers},o.prototype.getTotalMarkers=function(){return this.markers.length},o.prototype.getClusters=function(){return this.clusters},o.prototype.getTotalClusters=function(){return this.clusters.length},o.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},o.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},o.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)},o.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)},o.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},o.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},o.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},o.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)},o.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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var o=e.fromDivPixelToLatLng(s);null!==o&&t.extend(o)}return t},o.prototype.redraw=function(){this.createClusters(0)},o.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)}},o.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,r=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(r),Math.sqrt(1-r))*6371},o.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},o.prototype.addToClosestCluster=function(t){for(var e,s=4e4,r=null,o=0;o<this.clusters.length;o++){var n=(e=this.clusters[o]).getCenter(),a=t.getPosition();if(n&&a){var l=this.distanceBetweenPoints(n,a);l<s&&(s=l,r=e)}}r&&r.isMarkerInClusterBounds(t)?r.addMarker(t):((e=new i(this)).addMarker(t),this.clusters.push(e))},o.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),r=((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)),o=this.getExtendedBounds(r),n=Math.min(t+this.batchSize,this.markers.length),a=t;a<n;a++){var l=this.markers[a];!l.isAdded&&this.isMarkerInBounds(l,o)&&(!this.ignoreHidden||this.ignoreHidden&&l.getVisible())&&this.addToClosestCluster(l)}if(n<this.markers.length)this.timerRefStatic=window.setTimeout((function(){e.createClusters(n)}),0);else{this.timerRefStatic=null,google.maps.event.trigger(this,"clusteringend",this);for(a=0;a<this.clusters.length;a++)this.clusters[a].updateIcon()}}},o.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},o}(google.maps.OverlayView);exports.Cluster=i,exports.ClusterIcon=e,exports.Clusterer=o; | ||
"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())}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(),r=e.getMap();null!==r&&"fitBounds"in r&&r.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var r=t.getZoom()||0;null!==i&&r>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),r=parseInt(i[1].replace(/^\s+|\s+$/g,""),10),n=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.style.cursor="pointer",this.div.style.position="absolute",this.div.style.top=null!==n?"".concat(n.y,"px"):"0",this.div.style.left=null!==n?"".concat(n.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.style.position="absolute",o.style.top="".concat(r,"px"),o.style.left="".concat(s,"px"),this.cluster.getClusterer().enableRetinaIcons||(o.style.clip="rect(-".concat(r,"px, -").concat(s+this.width,"px, -").concat(r+this.height,", -").concat(s,")"));var a=document.createElement("div");a.style.position="absolute",a.style.top="".concat(this.anchorText[0],"px"),a.style.left="".concat(this.anchorText[1],"px"),a.style.color=this.textColor,a.style.fontSize="".concat(this.textSize,"px"),a.style.fontFamily=this.fontFamily,a.style.fontWeight=this.fontWeight,a.style.fontStyle=this.fontStyle,a.style.textDecoration=this.textDecoration,a.style.textAlign="center",a.style.width="".concat(this.width,"px"),a.style.lineHeight="".concat(this.height,"px"),a.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(a),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())}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 r=this.markers.length,n=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==n&&void 0!==o&&o>n)t.getMap()!==this.map&&t.setMap(this.map);else if(r<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(r===this.minClusterSize)for(var a=0;a<r;a++)this.markers[a].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}(),i=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},s=[53,56,66,78,90],r=function(){function t(e,r,n){void 0===r&&(r=[]),void 0===n&&(n={}),this.extend(t,google.maps.OverlayView),this.markers=[],this.clusters=[],this.listeners=[],this.activeMap=null,this.ready=!1,this.gridSize=n.gridSize||60,this.minClusterSize=n.minimumClusterSize||2,this.maxZoom=n.maxZoom||null,this.styles=n.styles||[],this.title=n.title||"",this.zoomOnClick=!0,void 0!==n.zoomOnClick&&(this.zoomOnClick=n.zoomOnClick),this.averageCenter=!1,void 0!==n.averageCenter&&(this.averageCenter=n.averageCenter),this.ignoreHidden=!1,void 0!==n.ignoreHidden&&(this.ignoreHidden=n.ignoreHidden),this.enableRetinaIcons=!1,void 0!==n.enableRetinaIcons&&(this.enableRetinaIcons=n.enableRetinaIcons),this.imagePath=n.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",this.imageExtension=n.imageExtension||"png",this.imageSizes=n.imageSizes||s,this.calculator=n.calculator||i,this.batchSize=n.batchSize||2e3,this.batchSizeIE=n.batchSizeIE||500,this.clusterClass=n.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize=this.batchSizeIE),this.timerRefStatic=null,this.setupStyles(),this.addMarkers(r,!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:this.imagePath+(t+1)+"."+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 r=this.getMap();null!==r&&"fitBounds"in r&&r.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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var n=e.fromDivPixelToLatLng(s);null!==n&&t.extend(n)}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,r=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(r),Math.sqrt(1-r))*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,r=null,n=0;n<this.clusters.length;n++){var o=(i=this.clusters[n]).getCenter(),a=t.getPosition();if(o&&a){var h=this.distanceBetweenPoints(o,a);h<s&&(s=h,r=i)}}r&&r.isMarkerInClusterBounds(t)?r.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),r=((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)),n=this.getExtendedBounds(r),o=Math.min(t+this.batchSize,this.markers.length),a=t;a<o;a++){var h=this.markers[a];!h.isAdded&&this.isMarkerInBounds(h,n)&&(!this.ignoreHidden||this.ignoreHidden&&h.getVisible())&&this.addToClosestCluster(h)}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(a=0;a<this.clusters.length;a++)this.clusters[a].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},t}();exports.Cluster=e,exports.ClusterIcon=t,exports.Clusterer=r; | ||
//# sourceMappingURL=cjs.min.js.map |
101
dist/esm.js
@@ -1,32 +0,1 @@ | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var ClusterIcon = /** @class */ (function () { | ||
@@ -408,2 +377,3 @@ function ClusterIcon(cluster, styles) { | ||
/* global google */ | ||
/** | ||
@@ -429,51 +399,48 @@ * Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers | ||
var CLUSTERER_CLASS = 'cluster'; | ||
var Clusterer = /** @class */ (function (_super) { | ||
__extends(Clusterer, _super); | ||
var Clusterer = /** @class */ (function () { | ||
function Clusterer(map, optMarkers, optOptions) { | ||
if (optMarkers === void 0) { optMarkers = []; } | ||
if (optOptions === void 0) { optOptions = {}; } | ||
var _this = _super.call(this) || this; | ||
_this.extend(Clusterer, google.maps.OverlayView); | ||
_this.markers = []; | ||
_this.clusters = []; | ||
_this.listeners = []; | ||
_this.activeMap = null; | ||
_this.ready = false; | ||
_this.gridSize = optOptions.gridSize || 60; | ||
_this.minClusterSize = optOptions.minimumClusterSize || 2; | ||
_this.maxZoom = optOptions.maxZoom || null; | ||
_this.styles = optOptions.styles || []; | ||
_this.title = optOptions.title || ''; | ||
_this.zoomOnClick = true; | ||
this.extend(Clusterer, google.maps.OverlayView); | ||
this.markers = []; | ||
this.clusters = []; | ||
this.listeners = []; | ||
this.activeMap = null; | ||
this.ready = false; | ||
this.gridSize = optOptions.gridSize || 60; | ||
this.minClusterSize = optOptions.minimumClusterSize || 2; | ||
this.maxZoom = optOptions.maxZoom || null; | ||
this.styles = optOptions.styles || []; | ||
this.title = optOptions.title || ''; | ||
this.zoomOnClick = true; | ||
if (optOptions.zoomOnClick !== undefined) { | ||
_this.zoomOnClick = optOptions.zoomOnClick; | ||
this.zoomOnClick = optOptions.zoomOnClick; | ||
} | ||
_this.averageCenter = false; | ||
this.averageCenter = false; | ||
if (optOptions.averageCenter !== undefined) { | ||
_this.averageCenter = optOptions.averageCenter; | ||
this.averageCenter = optOptions.averageCenter; | ||
} | ||
_this.ignoreHidden = false; | ||
this.ignoreHidden = false; | ||
if (optOptions.ignoreHidden !== undefined) { | ||
_this.ignoreHidden = optOptions.ignoreHidden; | ||
this.ignoreHidden = optOptions.ignoreHidden; | ||
} | ||
_this.enableRetinaIcons = false; | ||
this.enableRetinaIcons = false; | ||
if (optOptions.enableRetinaIcons !== undefined) { | ||
_this.enableRetinaIcons = optOptions.enableRetinaIcons; | ||
this.enableRetinaIcons = optOptions.enableRetinaIcons; | ||
} | ||
_this.imagePath = optOptions.imagePath || IMAGE_PATH; | ||
_this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION; | ||
_this.imageSizes = optOptions.imageSizes || IMAGE_SIZES; | ||
_this.calculator = optOptions.calculator || CALCULATOR; | ||
_this.batchSize = optOptions.batchSize || BATCH_SIZE; | ||
_this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE; | ||
_this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS; | ||
this.imagePath = optOptions.imagePath || IMAGE_PATH; | ||
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION; | ||
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES; | ||
this.calculator = optOptions.calculator || CALCULATOR; | ||
this.batchSize = optOptions.batchSize || BATCH_SIZE; | ||
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE; | ||
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS; | ||
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) { | ||
// Try to avoid IE timeout when processing a huge number of markers: | ||
_this.batchSize = _this.batchSizeIE; | ||
this.batchSize = this.batchSizeIE; | ||
} | ||
_this.timerRefStatic = null; | ||
_this.setupStyles(); | ||
_this.addMarkers(optMarkers, true); | ||
_this.setMap(map); // Note: this causes onAdd to be called | ||
return _this; | ||
this.timerRefStatic = null; | ||
this.setupStyles(); | ||
this.addMarkers(optMarkers, true); | ||
this.setMap(map); // Note: this causes onAdd to be called | ||
} | ||
@@ -909,5 +876,5 @@ Clusterer.prototype.onZoomChanged = function () { | ||
return Clusterer; | ||
}(google.maps.OverlayView)); | ||
}()); | ||
export { Cluster, ClusterIcon, Clusterer }; | ||
//# sourceMappingURL=esm.js.map |
@@ -1,2 +0,2 @@ | ||
var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};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())}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(),r=e.getMap();null!==r&&"fitBounds"in r&&r.fitBounds(s),this.timeOut=window.setTimeout((function(){var t=e.getMap();if(null!==t){"fitBounds"in t&&t.fitBounds(s);var r=t.getZoom()||0;null!==i&&r>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),r=parseInt(i[1].replace(/^\s+|\s+$/g,""),10),n=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.style.cursor="pointer",this.div.style.position="absolute",this.div.style.top=null!==n?"".concat(n.y,"px"):"0",this.div.style.left=null!==n?"".concat(n.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.style.position="absolute",o.style.top="".concat(r,"px"),o.style.left="".concat(s,"px"),this.cluster.getClusterer().enableRetinaIcons||(o.style.clip="rect(-".concat(r,"px, -").concat(s+this.width,"px, -").concat(r+this.height,", -").concat(s,")"));var a=document.createElement("div");a.style.position="absolute",a.style.top="".concat(this.anchorText[0],"px"),a.style.left="".concat(this.anchorText[1],"px"),a.style.color=this.textColor,a.style.fontSize="".concat(this.textSize,"px"),a.style.fontFamily=this.fontFamily,a.style.fontWeight=this.fontWeight,a.style.fontStyle=this.fontStyle,a.style.textDecoration=this.textDecoration,a.style.textAlign="center",a.style.width="".concat(this.width,"px"),a.style.lineHeight="".concat(this.height,"px"),a.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(a),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())}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 r=this.markers.length,n=this.markerClusterer.getMaxZoom(),o=null===(e=this.map)||void 0===e?void 0:e.getZoom();if(null!==n&&void 0!==o&&o>n)t.getMap()!==this.map&&t.setMap(this.map);else if(r<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(r===this.minClusterSize)for(var a=0;a<r;a++)this.markers[a].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}(),s=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},r=[53,56,66,78,90],n=function(e){function n(t,i,o){void 0===i&&(i=[]),void 0===o&&(o={});var a=e.call(this)||this;return a.extend(n,google.maps.OverlayView),a.markers=[],a.clusters=[],a.listeners=[],a.activeMap=null,a.ready=!1,a.gridSize=o.gridSize||60,a.minClusterSize=o.minimumClusterSize||2,a.maxZoom=o.maxZoom||null,a.styles=o.styles||[],a.title=o.title||"",a.zoomOnClick=!0,void 0!==o.zoomOnClick&&(a.zoomOnClick=o.zoomOnClick),a.averageCenter=!1,void 0!==o.averageCenter&&(a.averageCenter=o.averageCenter),a.ignoreHidden=!1,void 0!==o.ignoreHidden&&(a.ignoreHidden=o.ignoreHidden),a.enableRetinaIcons=!1,void 0!==o.enableRetinaIcons&&(a.enableRetinaIcons=o.enableRetinaIcons),a.imagePath=o.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",a.imageExtension=o.imageExtension||"png",a.imageSizes=o.imageSizes||r,a.calculator=o.calculator||s,a.batchSize=o.batchSize||2e3,a.batchSizeIE=o.batchSizeIE||500,a.clusterClass=o.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(a.batchSize=a.batchSizeIE),a.timerRefStatic=null,a.setupStyles(),a.addMarkers(i,!0),a.setMap(t),a}return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}(n,e),n.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")},n.prototype.onIdle=function(){this.redraw()},n.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)])},n.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},n.prototype.draw=function(){},n.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:this.imagePath+(t+1)+"."+this.imageExtension,height:this.imageSizes[t],width:this.imageSizes[t]})},n.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 r=this.getMap();null!==r&&"fitBounds"in r&&r.fitBounds(e)},n.prototype.getGridSize=function(){return this.gridSize},n.prototype.setGridSize=function(t){this.gridSize=t},n.prototype.getMinimumClusterSize=function(){return this.minClusterSize},n.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},n.prototype.getMaxZoom=function(){return this.maxZoom},n.prototype.setMaxZoom=function(t){this.maxZoom=t},n.prototype.getStyles=function(){return this.styles},n.prototype.setStyles=function(t){this.styles=t},n.prototype.getTitle=function(){return this.title},n.prototype.setTitle=function(t){this.title=t},n.prototype.getZoomOnClick=function(){return this.zoomOnClick},n.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},n.prototype.getAverageCenter=function(){return this.averageCenter},n.prototype.setAverageCenter=function(t){this.averageCenter=t},n.prototype.getIgnoreHidden=function(){return this.ignoreHidden},n.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},n.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},n.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},n.prototype.getImageExtension=function(){return this.imageExtension},n.prototype.setImageExtension=function(t){this.imageExtension=t},n.prototype.getImagePath=function(){return this.imagePath},n.prototype.setImagePath=function(t){this.imagePath=t},n.prototype.getImageSizes=function(){return this.imageSizes},n.prototype.setImageSizes=function(t){this.imageSizes=t},n.prototype.getCalculator=function(){return this.calculator},n.prototype.setCalculator=function(t){this.calculator=t},n.prototype.getBatchSizeIE=function(){return this.batchSizeIE},n.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},n.prototype.getClusterClass=function(){return this.clusterClass},n.prototype.setClusterClass=function(t){this.clusterClass=t},n.prototype.getMarkers=function(){return this.markers},n.prototype.getTotalMarkers=function(){return this.markers.length},n.prototype.getClusters=function(){return this.clusters},n.prototype.getTotalClusters=function(){return this.clusters.length},n.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},n.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},n.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)},n.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)},n.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},n.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},n.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},n.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)},n.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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var n=e.fromDivPixelToLatLng(s);null!==n&&t.extend(n)}return t},n.prototype.redraw=function(){this.createClusters(0)},n.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)}},n.prototype.distanceBetweenPoints=function(t,e){var i=(e.lat()-t.lat())*Math.PI/180,s=(e.lng()-t.lng())*Math.PI/180,r=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(r),Math.sqrt(1-r))*6371},n.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},n.prototype.addToClosestCluster=function(t){for(var e,s=4e4,r=null,n=0;n<this.clusters.length;n++){var o=(e=this.clusters[n]).getCenter(),a=t.getPosition();if(o&&a){var l=this.distanceBetweenPoints(o,a);l<s&&(s=l,r=e)}}r&&r.isMarkerInClusterBounds(t)?r.addMarker(t):((e=new i(this)).addMarker(t),this.clusters.push(e))},n.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),r=((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)),n=this.getExtendedBounds(r),o=Math.min(t+this.batchSize,this.markers.length),a=t;a<o;a++){var l=this.markers[a];!l.isAdded&&this.isMarkerInBounds(l,n)&&(!this.ignoreHidden||this.ignoreHidden&&l.getVisible())&&this.addToClosestCluster(l)}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(a=0;a<this.clusters.length;a++)this.clusters[a].updateIcon()}}},n.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},n}(google.maps.OverlayView);export{i as Cluster,e 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())}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.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.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 a=document.createElement("div");a.style.position="absolute",a.style.top="".concat(this.anchorText[0],"px"),a.style.left="".concat(this.anchorText[1],"px"),a.style.color=this.textColor,a.style.fontSize="".concat(this.textSize,"px"),a.style.fontFamily=this.fontFamily,a.style.fontWeight=this.fontWeight,a.style.fontStyle=this.fontStyle,a.style.textDecoration=this.textDecoration,a.style.textAlign="center",a.style.width="".concat(this.width,"px"),a.style.lineHeight="".concat(this.height,"px"),a.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(a),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())}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 a=0;a<n;a++)this.markers[a].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}(),i=function(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}},s=[53,56,66,78,90],n=function(){function t(e,n,r){void 0===n&&(n=[]),void 0===r&&(r={}),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:this.imagePath+(t+1)+"."+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(),a=t.getPosition();if(o&&a){var h=this.distanceBetweenPoints(o,a);h<s&&(s=h,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),a=t;a<o;a++){var h=this.markers[a];!h.isAdded&&this.isMarkerInBounds(h,r)&&(!this.ignoreHidden||this.ignoreHidden&&h.getVisible())&&this.addToClosestCluster(h)}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(a=0;a<this.clusters.length;a++)this.clusters[a].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},t}();export{e as Cluster,t as ClusterIcon,n as Clusterer}; | ||
//# sourceMappingURL=esm.min.js.map |
@@ -110,3 +110,3 @@ interface ClusterIconInfo { | ||
declare class Clusterer extends google.maps.OverlayView { | ||
declare class Clusterer { | ||
markers: MarkerExtended[]; | ||
@@ -113,0 +113,0 @@ clusters: Cluster[]; |
101
dist/umd.js
@@ -7,33 +7,2 @@ (function (global, factory) { | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
var ClusterIcon = /** @class */ (function () { | ||
@@ -415,2 +384,3 @@ function ClusterIcon(cluster, styles) { | ||
/* global google */ | ||
/** | ||
@@ -436,51 +406,48 @@ * Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers | ||
var CLUSTERER_CLASS = 'cluster'; | ||
var Clusterer = /** @class */ (function (_super) { | ||
__extends(Clusterer, _super); | ||
var Clusterer = /** @class */ (function () { | ||
function Clusterer(map, optMarkers, optOptions) { | ||
if (optMarkers === void 0) { optMarkers = []; } | ||
if (optOptions === void 0) { optOptions = {}; } | ||
var _this = _super.call(this) || this; | ||
_this.extend(Clusterer, google.maps.OverlayView); | ||
_this.markers = []; | ||
_this.clusters = []; | ||
_this.listeners = []; | ||
_this.activeMap = null; | ||
_this.ready = false; | ||
_this.gridSize = optOptions.gridSize || 60; | ||
_this.minClusterSize = optOptions.minimumClusterSize || 2; | ||
_this.maxZoom = optOptions.maxZoom || null; | ||
_this.styles = optOptions.styles || []; | ||
_this.title = optOptions.title || ''; | ||
_this.zoomOnClick = true; | ||
this.extend(Clusterer, google.maps.OverlayView); | ||
this.markers = []; | ||
this.clusters = []; | ||
this.listeners = []; | ||
this.activeMap = null; | ||
this.ready = false; | ||
this.gridSize = optOptions.gridSize || 60; | ||
this.minClusterSize = optOptions.minimumClusterSize || 2; | ||
this.maxZoom = optOptions.maxZoom || null; | ||
this.styles = optOptions.styles || []; | ||
this.title = optOptions.title || ''; | ||
this.zoomOnClick = true; | ||
if (optOptions.zoomOnClick !== undefined) { | ||
_this.zoomOnClick = optOptions.zoomOnClick; | ||
this.zoomOnClick = optOptions.zoomOnClick; | ||
} | ||
_this.averageCenter = false; | ||
this.averageCenter = false; | ||
if (optOptions.averageCenter !== undefined) { | ||
_this.averageCenter = optOptions.averageCenter; | ||
this.averageCenter = optOptions.averageCenter; | ||
} | ||
_this.ignoreHidden = false; | ||
this.ignoreHidden = false; | ||
if (optOptions.ignoreHidden !== undefined) { | ||
_this.ignoreHidden = optOptions.ignoreHidden; | ||
this.ignoreHidden = optOptions.ignoreHidden; | ||
} | ||
_this.enableRetinaIcons = false; | ||
this.enableRetinaIcons = false; | ||
if (optOptions.enableRetinaIcons !== undefined) { | ||
_this.enableRetinaIcons = optOptions.enableRetinaIcons; | ||
this.enableRetinaIcons = optOptions.enableRetinaIcons; | ||
} | ||
_this.imagePath = optOptions.imagePath || IMAGE_PATH; | ||
_this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION; | ||
_this.imageSizes = optOptions.imageSizes || IMAGE_SIZES; | ||
_this.calculator = optOptions.calculator || CALCULATOR; | ||
_this.batchSize = optOptions.batchSize || BATCH_SIZE; | ||
_this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE; | ||
_this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS; | ||
this.imagePath = optOptions.imagePath || IMAGE_PATH; | ||
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION; | ||
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES; | ||
this.calculator = optOptions.calculator || CALCULATOR; | ||
this.batchSize = optOptions.batchSize || BATCH_SIZE; | ||
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE; | ||
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS; | ||
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) { | ||
// Try to avoid IE timeout when processing a huge number of markers: | ||
_this.batchSize = _this.batchSizeIE; | ||
this.batchSize = this.batchSizeIE; | ||
} | ||
_this.timerRefStatic = null; | ||
_this.setupStyles(); | ||
_this.addMarkers(optMarkers, true); | ||
_this.setMap(map); // Note: this causes onAdd to be called | ||
return _this; | ||
this.timerRefStatic = null; | ||
this.setupStyles(); | ||
this.addMarkers(optMarkers, true); | ||
this.setMap(map); // Note: this causes onAdd to be called | ||
} | ||
@@ -916,3 +883,3 @@ Clusterer.prototype.onZoomChanged = function () { | ||
return Clusterer; | ||
}(google.maps.OverlayView)); | ||
}()); | ||
@@ -919,0 +886,0 @@ exports.Cluster = Cluster; |
@@ -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(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},e(t,i)};var i=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())}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.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.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 a=document.createElement("div");a.style.position="absolute",a.style.top="".concat(this.anchorText[0],"px"),a.style.left="".concat(this.anchorText[1],"px"),a.style.color=this.textColor,a.style.fontSize="".concat(this.textSize,"px"),a.style.fontFamily=this.fontFamily,a.style.fontWeight=this.fontWeight,a.style.fontStyle=this.fontStyle,a.style.textDecoration=this.textDecoration,a.style.textAlign="center",a.style.width="".concat(this.width,"px"),a.style.lineHeight="".concat(this.height,"px"),a.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(a),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}(),s=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 i(this,this.markerClusterer.getStyles())}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 a=0;a<n;a++)this.markers[a].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}(),n=function(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}},r=[53,56,66,78,90],o=function(t){function i(e,s,o){void 0===s&&(s=[]),void 0===o&&(o={});var a=t.call(this)||this;return a.extend(i,google.maps.OverlayView),a.markers=[],a.clusters=[],a.listeners=[],a.activeMap=null,a.ready=!1,a.gridSize=o.gridSize||60,a.minClusterSize=o.minimumClusterSize||2,a.maxZoom=o.maxZoom||null,a.styles=o.styles||[],a.title=o.title||"",a.zoomOnClick=!0,void 0!==o.zoomOnClick&&(a.zoomOnClick=o.zoomOnClick),a.averageCenter=!1,void 0!==o.averageCenter&&(a.averageCenter=o.averageCenter),a.ignoreHidden=!1,void 0!==o.ignoreHidden&&(a.ignoreHidden=o.ignoreHidden),a.enableRetinaIcons=!1,void 0!==o.enableRetinaIcons&&(a.enableRetinaIcons=o.enableRetinaIcons),a.imagePath=o.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",a.imageExtension=o.imageExtension||"png",a.imageSizes=o.imageSizes||r,a.calculator=o.calculator||n,a.batchSize=o.batchSize||2e3,a.batchSizeIE=o.batchSizeIE||500,a.clusterClass=o.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(a.batchSize=a.batchSizeIE),a.timerRefStatic=null,a.setupStyles(),a.addMarkers(s,!0),a.setMap(e),a}return function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}(i,t),i.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")},i.prototype.onIdle=function(){this.redraw()},i.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)])},i.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},i.prototype.draw=function(){},i.prototype.setupStyles=function(){if(!(this.styles.length>0))for(var t=0;t<this.imageSizes.length;t++)this.styles.push({url:this.imagePath+(t+1)+"."+this.imageExtension,height:this.imageSizes[t],width:this.imageSizes[t]})},i.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)},i.prototype.getGridSize=function(){return this.gridSize},i.prototype.setGridSize=function(t){this.gridSize=t},i.prototype.getMinimumClusterSize=function(){return this.minClusterSize},i.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},i.prototype.getMaxZoom=function(){return this.maxZoom},i.prototype.setMaxZoom=function(t){this.maxZoom=t},i.prototype.getStyles=function(){return this.styles},i.prototype.setStyles=function(t){this.styles=t},i.prototype.getTitle=function(){return this.title},i.prototype.setTitle=function(t){this.title=t},i.prototype.getZoomOnClick=function(){return this.zoomOnClick},i.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},i.prototype.getAverageCenter=function(){return this.averageCenter},i.prototype.setAverageCenter=function(t){this.averageCenter=t},i.prototype.getIgnoreHidden=function(){return this.ignoreHidden},i.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},i.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},i.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},i.prototype.getImageExtension=function(){return this.imageExtension},i.prototype.setImageExtension=function(t){this.imageExtension=t},i.prototype.getImagePath=function(){return this.imagePath},i.prototype.setImagePath=function(t){this.imagePath=t},i.prototype.getImageSizes=function(){return this.imageSizes},i.prototype.setImageSizes=function(t){this.imageSizes=t},i.prototype.getCalculator=function(){return this.calculator},i.prototype.setCalculator=function(t){this.calculator=t},i.prototype.getBatchSizeIE=function(){return this.batchSizeIE},i.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},i.prototype.getClusterClass=function(){return this.clusterClass},i.prototype.setClusterClass=function(t){this.clusterClass=t},i.prototype.getMarkers=function(){return this.markers},i.prototype.getTotalMarkers=function(){return this.markers.length},i.prototype.getClusters=function(){return this.clusters},i.prototype.getTotalClusters=function(){return this.clusters.length},i.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},i.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},i.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)},i.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)},i.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},i.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},i.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},i.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)},i.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},i.prototype.redraw=function(){this.createClusters(0)},i.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)}},i.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},i.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},i.prototype.addToClosestCluster=function(t){for(var e,i=4e4,n=null,r=0;r<this.clusters.length;r++){var o=(e=this.clusters[r]).getCenter(),a=t.getPosition();if(o&&a){var l=this.distanceBetweenPoints(o,a);l<i&&(i=l,n=e)}}n&&n.isMarkerInClusterBounds(t)?n.addMarker(t):((e=new s(this)).addMarker(t),this.clusters.push(e))},i.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),a=t;a<o;a++){var l=this.markers[a];!l.isAdded&&this.isMarkerInBounds(l,r)&&(!this.ignoreHidden||this.ignoreHidden&&l.getVisible())&&this.addToClosestCluster(l)}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(a=0;a<this.clusters.length;a++)this.clusters[a].updateIcon()}}},i.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},i}(google.maps.OverlayView);t.Cluster=s,t.ClusterIcon=i,t.Clusterer=o,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())}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.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.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 a=document.createElement("div");a.style.position="absolute",a.style.top="".concat(this.anchorText[0],"px"),a.style.left="".concat(this.anchorText[1],"px"),a.style.color=this.textColor,a.style.fontSize="".concat(this.textSize,"px"),a.style.fontFamily=this.fontFamily,a.style.fontWeight=this.fontWeight,a.style.fontStyle=this.fontStyle,a.style.textDecoration=this.textDecoration,a.style.textAlign="center",a.style.width="".concat(this.width,"px"),a.style.lineHeight="".concat(this.height,"px"),a.innerText="".concat(null===(t=this.sums)||void 0===t?void 0:t.text),this.div.innerHTML="",this.div.appendChild(o),this.div.appendChild(a),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())}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 a=0;a<n;a++)this.markers[a].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}(),s=function(t,e){var i=t.length,s=i.toString().length,n=Math.min(s,e);return{text:i.toString(),index:n,title:""}},n=[53,56,66,78,90],r=function(){function t(e,i,r){void 0===i&&(i=[]),void 0===r&&(r={}),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:this.imagePath+(t+1)+"."+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(),a=t.getPosition();if(o&&a){var h=this.distanceBetweenPoints(o,a);h<s&&(s=h,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),a=t;a<o;a++){var h=this.markers[a];!h.isAdded&&this.isMarkerInBounds(h,r)&&(!this.ignoreHidden||this.ignoreHidden&&h.getVisible())&&this.addToClosestCluster(h)}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(a=0;a<this.clusters.length;a++)this.clusters[a].updateIcon()}}},t.prototype.extend=function(t,e){return function(t){for(var e in t.prototype)this.prototype.set(e,t.prototype.get(e));return this}.apply(t,[e])},t}();t.Cluster=i,t.ClusterIcon=e,t.Clusterer=r,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=umd.min.js.map |
{ | ||
"name": "@react-google-maps/marker-clusterer", | ||
"sideEffects": false, | ||
"version": "2.11.2", | ||
"version": "2.11.3", | ||
"description": "Marker Clusterer for React.js Google Maps API", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
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
571252
4172