@react-google-maps/marker-clusterer
Advanced tools
Comparing version 2.11.0 to 2.11.1
@@ -93,18 +93,19 @@ 'use strict'; | ||
var bounds_1 = this.cluster.getBounds(); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().fitBounds(bounds_1); | ||
var map = markerClusterer_1.getMap(); | ||
if (map !== null && 'fitBounds' in map) { | ||
map.fitBounds(bounds_1); | ||
} | ||
// There is a fix for Issue 170 here: | ||
this.timeOut = window.setTimeout(function () { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().fitBounds(bounds_1); | ||
// Don't zoom beyond the max zoom level | ||
if (maxZoom_1 !== null && | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().getZoom() > maxZoom_1) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().setZoom(maxZoom_1 + 1); | ||
var map = markerClusterer_1.getMap(); | ||
if (map !== null) { | ||
if ('fitBounds' in map) { | ||
map.fitBounds(bounds_1); | ||
} | ||
var zoom = map.getZoom() || 0; | ||
// Don't zoom beyond the max zoom level | ||
if (maxZoom_1 !== null && | ||
zoom > maxZoom_1) { | ||
map.setZoom(maxZoom_1 + 1); | ||
} | ||
} | ||
@@ -139,2 +140,3 @@ }, 100); | ||
ClusterIcon.prototype.onAdd = function () { | ||
var _a; | ||
this.div = document.createElement('div'); | ||
@@ -145,14 +147,12 @@ this.div.className = this.className; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getPanes().overlayMouseTarget.appendChild(this.div); | ||
// Fix for Issue 157 | ||
this.boundsChangedListener = google.maps.event.addListener( | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getMap(), '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); | ||
(_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div); | ||
var map = this.getMap(); | ||
if (map !== null) { | ||
// Fix for Issue 157 | ||
this.boundsChangedListener = google.maps.event.addListener(map, '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); | ||
} | ||
}; | ||
@@ -280,4 +280,2 @@ ClusterIcon.prototype.onRemove = function () { | ||
this.markerClusterer = markerClusterer; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.map = this.markerClusterer.getMap(); | ||
@@ -319,4 +317,2 @@ this.gridSize = this.markerClusterer.getGridSize(); | ||
Cluster.prototype.remove = function () { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.clusterIcon.setMap(null); | ||
@@ -329,2 +325,3 @@ this.markers = []; | ||
Cluster.prototype.addMarker = function (marker) { | ||
var _a; | ||
if (this.isMarkerAlreadyAdded(marker)) { | ||
@@ -354,3 +351,3 @@ return false; | ||
var maxZoom = this.markerClusterer.getMaxZoom(); | ||
var zoom = this.map.getZoom(); | ||
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom(); | ||
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) { | ||
@@ -392,5 +389,6 @@ // Zoomed in past max zoom, so show the marker. | ||
Cluster.prototype.updateIcon = function () { | ||
var _a; | ||
var mCount = this.markers.length; | ||
var maxZoom = this.markerClusterer.getMaxZoom(); | ||
var zoom = this.map.getZoom(); | ||
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom(); | ||
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) { | ||
@@ -492,4 +490,2 @@ this.clusterIcon.hide(); | ||
_this.addMarkers(optMarkers, true); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
_this.setMap(map); // Note: this causes onAdd to be called | ||
@@ -570,5 +566,6 @@ return _this; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getMap().fitBounds(bounds); | ||
var map = this.getMap(); | ||
if (map !== null && 'fitBounds' in map) { | ||
map.fitBounds(bounds); | ||
} | ||
}; | ||
@@ -763,4 +760,2 @@ Clusterer.prototype.getGridSize = function () { | ||
Clusterer.prototype.getExtendedBounds = function (bounds) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var projection = this.getProjection(); | ||
@@ -885,2 +880,3 @@ // Convert the points to pixels and the extend out by the grid size. | ||
var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null; | ||
var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0; | ||
// Get our current map view bounds. | ||
@@ -890,6 +886,3 @@ // Create a new bounds object so we don't affect the map. | ||
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug: | ||
var mapBounds = | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
map.getZoom() > 3 | ||
var mapBounds = zoom > 3 | ||
? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast()) | ||
@@ -896,0 +889,0 @@ : new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625)); |
@@ -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)};function e(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)}var i=function(t){function i(e,s){var r=t.call(this)||this;return e.getClusterer().extend(i,google.maps.OverlayView),r.cluster=e,r.clusterClassName=r.cluster.getClusterer().getClusterClass(),r.className=r.clusterClassName,r.styles=s,r.center=void 0,r.div=null,r.sums=null,r.visible=!1,r.boundsChangedListener=null,r.url="",r.height=0,r.width=0,r.anchorText=[0,0],r.anchorIcon=[0,0],r.textColor="black",r.textSize=11,r.textDecoration="none",r.fontWeight="bold",r.fontStyle="normal",r.fontFamily="Arial,sans-serif",r.backgroundPosition="0 0",r.cMouseDownInCluster=null,r.cDraggingMapByCluster=null,r.timeOut=null,r.setMap(e.getMap()),r}return e(i,t),i.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},i.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},i.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();e.getMap().fitBounds(s),this.timeOut=window.setTimeout((function(){e.getMap().fitBounds(s),null!==i&&e.getMap().getZoom()>i&&e.getMap().setZoom(i+1)}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},i.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},i.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},i.prototype.onAdd=function(){this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),this.getPanes().overlayMouseTarget.appendChild(this.div),this.boundsChangedListener=google.maps.event.addListener(this.getMap(),"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)},i.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)},i.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"}},i.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},i.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},i.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"},i.prototype.setCenter=function(t){this.center=t},i.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},i}(google.maps.OverlayView),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){if(this.isMarkerAlreadyAdded(t))return!1;var e;if(this.center){if(this.averageCenter&&(e=t.getPosition())){var i=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(i-1)+e.lat())/i,(this.center.lng()*(i-1)+e.lng())/i),this.calculateBounds()}}else(e=t.getPosition())&&(this.center=e,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var s=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=this.map.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(s<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(s===this.minClusterSize)for(var n=0;n<s;n++)this.markers[n].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=this.markers.length,e=this.markerClusterer.getMaxZoom(),i=this.map.getZoom();null!==e&&void 0!==i&&i>e||t<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}(),r=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},o=[53,56,66,78,90],n=function(t){function i(e,s,n){void 0===s&&(s=[]),void 0===n&&(n={});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=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||o,a.calculator=n.calculator||r,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(s,!0),a.setMap(e),a}return e(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)}this.getMap().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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var o=e.fromDivPixelToLatLng(s);null!==o&&t.extend(o)}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,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},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,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<i&&(i=l,r=e)}}r&&r.isMarkerInClusterBounds(t)?r.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),r=i.getZoom()>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()}}},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);exports.Cluster=s,exports.ClusterIcon=i,exports.Clusterer=n; | ||
"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)};function e(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)}var i=function(t){function i(e,s){var r=t.call(this)||this;return e.getClusterer().extend(i,google.maps.OverlayView),r.cluster=e,r.clusterClassName=r.cluster.getClusterer().getClusterClass(),r.className=r.clusterClassName,r.styles=s,r.center=void 0,r.div=null,r.sums=null,r.visible=!1,r.boundsChangedListener=null,r.url="",r.height=0,r.width=0,r.anchorText=[0,0],r.anchorIcon=[0,0],r.textColor="black",r.textSize=11,r.textDecoration="none",r.fontWeight="bold",r.fontStyle="normal",r.fontFamily="Arial,sans-serif",r.backgroundPosition="0 0",r.cMouseDownInCluster=null,r.cDraggingMapByCluster=null,r.timeOut=null,r.setMap(e.getMap()),r}return e(i,t),i.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},i.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},i.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()}},i.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},i.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},i.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))},i.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)},i.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"}},i.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},i.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},i.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"},i.prototype.setCenter=function(t){this.center=t},i.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},i}(google.maps.OverlayView),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 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}(),r=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},o=[53,56,66,78,90],n=function(t){function i(e,s,n){void 0===s&&(s=[]),void 0===n&&(n={});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=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||o,a.calculator=n.calculator||r,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(s,!0),a.setMap(e),a}return e(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 r=this.getMap();null!==r&&"fitBounds"in r&&r.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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var o=e.fromDivPixelToLatLng(s);null!==o&&t.extend(o)}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,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},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,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<i&&(i=l,r=e)}}r&&r.isMarkerInClusterBounds(t)?r.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),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()}}},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);exports.Cluster=s,exports.ClusterIcon=i,exports.Clusterer=n; | ||
//# sourceMappingURL=cjs.min.js.map |
@@ -89,18 +89,19 @@ /****************************************************************************** | ||
var bounds_1 = this.cluster.getBounds(); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().fitBounds(bounds_1); | ||
var map = markerClusterer_1.getMap(); | ||
if (map !== null && 'fitBounds' in map) { | ||
map.fitBounds(bounds_1); | ||
} | ||
// There is a fix for Issue 170 here: | ||
this.timeOut = window.setTimeout(function () { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().fitBounds(bounds_1); | ||
// Don't zoom beyond the max zoom level | ||
if (maxZoom_1 !== null && | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().getZoom() > maxZoom_1) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().setZoom(maxZoom_1 + 1); | ||
var map = markerClusterer_1.getMap(); | ||
if (map !== null) { | ||
if ('fitBounds' in map) { | ||
map.fitBounds(bounds_1); | ||
} | ||
var zoom = map.getZoom() || 0; | ||
// Don't zoom beyond the max zoom level | ||
if (maxZoom_1 !== null && | ||
zoom > maxZoom_1) { | ||
map.setZoom(maxZoom_1 + 1); | ||
} | ||
} | ||
@@ -135,2 +136,3 @@ }, 100); | ||
ClusterIcon.prototype.onAdd = function () { | ||
var _a; | ||
this.div = document.createElement('div'); | ||
@@ -141,14 +143,12 @@ this.div.className = this.className; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getPanes().overlayMouseTarget.appendChild(this.div); | ||
// Fix for Issue 157 | ||
this.boundsChangedListener = google.maps.event.addListener( | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getMap(), '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); | ||
(_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div); | ||
var map = this.getMap(); | ||
if (map !== null) { | ||
// Fix for Issue 157 | ||
this.boundsChangedListener = google.maps.event.addListener(map, '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); | ||
} | ||
}; | ||
@@ -276,4 +276,2 @@ ClusterIcon.prototype.onRemove = function () { | ||
this.markerClusterer = markerClusterer; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.map = this.markerClusterer.getMap(); | ||
@@ -315,4 +313,2 @@ this.gridSize = this.markerClusterer.getGridSize(); | ||
Cluster.prototype.remove = function () { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.clusterIcon.setMap(null); | ||
@@ -325,2 +321,3 @@ this.markers = []; | ||
Cluster.prototype.addMarker = function (marker) { | ||
var _a; | ||
if (this.isMarkerAlreadyAdded(marker)) { | ||
@@ -350,3 +347,3 @@ return false; | ||
var maxZoom = this.markerClusterer.getMaxZoom(); | ||
var zoom = this.map.getZoom(); | ||
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom(); | ||
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) { | ||
@@ -388,5 +385,6 @@ // Zoomed in past max zoom, so show the marker. | ||
Cluster.prototype.updateIcon = function () { | ||
var _a; | ||
var mCount = this.markers.length; | ||
var maxZoom = this.markerClusterer.getMaxZoom(); | ||
var zoom = this.map.getZoom(); | ||
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom(); | ||
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) { | ||
@@ -488,4 +486,2 @@ this.clusterIcon.hide(); | ||
_this.addMarkers(optMarkers, true); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
_this.setMap(map); // Note: this causes onAdd to be called | ||
@@ -566,5 +562,6 @@ return _this; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getMap().fitBounds(bounds); | ||
var map = this.getMap(); | ||
if (map !== null && 'fitBounds' in map) { | ||
map.fitBounds(bounds); | ||
} | ||
}; | ||
@@ -759,4 +756,2 @@ Clusterer.prototype.getGridSize = function () { | ||
Clusterer.prototype.getExtendedBounds = function (bounds) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var projection = this.getProjection(); | ||
@@ -881,2 +876,3 @@ // Convert the points to pixels and the extend out by the grid size. | ||
var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null; | ||
var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0; | ||
// Get our current map view bounds. | ||
@@ -886,6 +882,3 @@ // Create a new bounds object so we don't affect the map. | ||
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug: | ||
var mapBounds = | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
map.getZoom() > 3 | ||
var mapBounds = zoom > 3 | ||
? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast()) | ||
@@ -892,0 +885,0 @@ : new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625)); |
@@ -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)};function e(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)}var i=function(t){function i(e,s){var r=t.call(this)||this;return e.getClusterer().extend(i,google.maps.OverlayView),r.cluster=e,r.clusterClassName=r.cluster.getClusterer().getClusterClass(),r.className=r.clusterClassName,r.styles=s,r.center=void 0,r.div=null,r.sums=null,r.visible=!1,r.boundsChangedListener=null,r.url="",r.height=0,r.width=0,r.anchorText=[0,0],r.anchorIcon=[0,0],r.textColor="black",r.textSize=11,r.textDecoration="none",r.fontWeight="bold",r.fontStyle="normal",r.fontFamily="Arial,sans-serif",r.backgroundPosition="0 0",r.cMouseDownInCluster=null,r.cDraggingMapByCluster=null,r.timeOut=null,r.setMap(e.getMap()),r}return e(i,t),i.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},i.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},i.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();e.getMap().fitBounds(s),this.timeOut=window.setTimeout((function(){e.getMap().fitBounds(s),null!==i&&e.getMap().getZoom()>i&&e.getMap().setZoom(i+1)}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},i.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},i.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},i.prototype.onAdd=function(){this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),this.getPanes().overlayMouseTarget.appendChild(this.div),this.boundsChangedListener=google.maps.event.addListener(this.getMap(),"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)},i.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)},i.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"}},i.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},i.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},i.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"},i.prototype.setCenter=function(t){this.center=t},i.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},i}(google.maps.OverlayView),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){if(this.isMarkerAlreadyAdded(t))return!1;var e;if(this.center){if(this.averageCenter&&(e=t.getPosition())){var i=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(i-1)+e.lat())/i,(this.center.lng()*(i-1)+e.lng())/i),this.calculateBounds()}}else(e=t.getPosition())&&(this.center=e,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var s=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=this.map.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(s<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(s===this.minClusterSize)for(var n=0;n<s;n++)this.markers[n].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=this.markers.length,e=this.markerClusterer.getMaxZoom(),i=this.map.getZoom();null!==e&&void 0!==i&&i>e||t<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}(),r=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},o=[53,56,66,78,90],n=function(t){function i(e,s,n){void 0===s&&(s=[]),void 0===n&&(n={});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=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||o,a.calculator=n.calculator||r,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(s,!0),a.setMap(e),a}return e(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)}this.getMap().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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var o=e.fromDivPixelToLatLng(s);null!==o&&t.extend(o)}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,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},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,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<i&&(i=l,r=e)}}r&&r.isMarkerInClusterBounds(t)?r.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),r=i.getZoom()>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()}}},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);export{s as Cluster,i as ClusterIcon,n as Clusterer}; | ||
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)};function e(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)}var i=function(t){function i(e,s){var r=t.call(this)||this;return e.getClusterer().extend(i,google.maps.OverlayView),r.cluster=e,r.clusterClassName=r.cluster.getClusterer().getClusterClass(),r.className=r.clusterClassName,r.styles=s,r.center=void 0,r.div=null,r.sums=null,r.visible=!1,r.boundsChangedListener=null,r.url="",r.height=0,r.width=0,r.anchorText=[0,0],r.anchorIcon=[0,0],r.textColor="black",r.textSize=11,r.textDecoration="none",r.fontWeight="bold",r.fontStyle="normal",r.fontFamily="Arial,sans-serif",r.backgroundPosition="0 0",r.cMouseDownInCluster=null,r.cDraggingMapByCluster=null,r.timeOut=null,r.setMap(e.getMap()),r}return e(i,t),i.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},i.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},i.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()}},i.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},i.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},i.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))},i.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)},i.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"}},i.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},i.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},i.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"},i.prototype.setCenter=function(t){this.center=t},i.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},i}(google.maps.OverlayView),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 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}(),r=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},n=[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||n,a.calculator=o.calculator||r,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 e(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 r=this.getMap();null!==r&&"fitBounds"in r&&r.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 r=e.fromDivPixelToLatLng(i);null!==r&&t.extend(r)}if(null!==s){var n=e.fromDivPixelToLatLng(s);null!==n&&t.extend(n)}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,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},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,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<i&&(i=l,r=e)}}r&&r.isMarkerInClusterBounds(t)?r.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),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()}}},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);export{s as Cluster,i as ClusterIcon,o as Clusterer}; | ||
//# sourceMappingURL=esm.min.js.map |
@@ -87,3 +87,3 @@ interface ClusterIconInfo { | ||
markerClusterer: Clusterer; | ||
map: google.maps.Map | google.maps.StreetViewPanorama; | ||
map: google.maps.Map | google.maps.StreetViewPanorama | null; | ||
gridSize: number; | ||
@@ -100,3 +100,3 @@ minClusterSize: number; | ||
getCenter(): google.maps.LatLng | undefined; | ||
getMap(): google.maps.Map | google.maps.StreetViewPanorama; | ||
getMap(): google.maps.Map | google.maps.StreetViewPanorama | null; | ||
getClusterer(): Clusterer; | ||
@@ -103,0 +103,0 @@ getBounds(): google.maps.LatLngBounds; |
@@ -95,18 +95,19 @@ (function (global, factory) { | ||
var bounds_1 = this.cluster.getBounds(); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().fitBounds(bounds_1); | ||
var map = markerClusterer_1.getMap(); | ||
if (map !== null && 'fitBounds' in map) { | ||
map.fitBounds(bounds_1); | ||
} | ||
// There is a fix for Issue 170 here: | ||
this.timeOut = window.setTimeout(function () { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().fitBounds(bounds_1); | ||
// Don't zoom beyond the max zoom level | ||
if (maxZoom_1 !== null && | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().getZoom() > maxZoom_1) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
markerClusterer_1.getMap().setZoom(maxZoom_1 + 1); | ||
var map = markerClusterer_1.getMap(); | ||
if (map !== null) { | ||
if ('fitBounds' in map) { | ||
map.fitBounds(bounds_1); | ||
} | ||
var zoom = map.getZoom() || 0; | ||
// Don't zoom beyond the max zoom level | ||
if (maxZoom_1 !== null && | ||
zoom > maxZoom_1) { | ||
map.setZoom(maxZoom_1 + 1); | ||
} | ||
} | ||
@@ -141,2 +142,3 @@ }, 100); | ||
ClusterIcon.prototype.onAdd = function () { | ||
var _a; | ||
this.div = document.createElement('div'); | ||
@@ -147,14 +149,12 @@ this.div.className = this.className; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getPanes().overlayMouseTarget.appendChild(this.div); | ||
// Fix for Issue 157 | ||
this.boundsChangedListener = google.maps.event.addListener( | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getMap(), '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); | ||
(_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div); | ||
var map = this.getMap(); | ||
if (map !== null) { | ||
// Fix for Issue 157 | ||
this.boundsChangedListener = google.maps.event.addListener(map, '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); | ||
} | ||
}; | ||
@@ -282,4 +282,2 @@ ClusterIcon.prototype.onRemove = function () { | ||
this.markerClusterer = markerClusterer; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.map = this.markerClusterer.getMap(); | ||
@@ -321,4 +319,2 @@ this.gridSize = this.markerClusterer.getGridSize(); | ||
Cluster.prototype.remove = function () { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.clusterIcon.setMap(null); | ||
@@ -331,2 +327,3 @@ this.markers = []; | ||
Cluster.prototype.addMarker = function (marker) { | ||
var _a; | ||
if (this.isMarkerAlreadyAdded(marker)) { | ||
@@ -356,3 +353,3 @@ return false; | ||
var maxZoom = this.markerClusterer.getMaxZoom(); | ||
var zoom = this.map.getZoom(); | ||
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom(); | ||
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) { | ||
@@ -394,5 +391,6 @@ // Zoomed in past max zoom, so show the marker. | ||
Cluster.prototype.updateIcon = function () { | ||
var _a; | ||
var mCount = this.markers.length; | ||
var maxZoom = this.markerClusterer.getMaxZoom(); | ||
var zoom = this.map.getZoom(); | ||
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom(); | ||
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) { | ||
@@ -494,4 +492,2 @@ this.clusterIcon.hide(); | ||
_this.addMarkers(optMarkers, true); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
_this.setMap(map); // Note: this causes onAdd to be called | ||
@@ -572,5 +568,6 @@ return _this; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.getMap().fitBounds(bounds); | ||
var map = this.getMap(); | ||
if (map !== null && 'fitBounds' in map) { | ||
map.fitBounds(bounds); | ||
} | ||
}; | ||
@@ -765,4 +762,2 @@ Clusterer.prototype.getGridSize = function () { | ||
Clusterer.prototype.getExtendedBounds = function (bounds) { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var projection = this.getProjection(); | ||
@@ -887,2 +882,3 @@ // Convert the points to pixels and the extend out by the grid size. | ||
var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null; | ||
var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0; | ||
// Get our current map view bounds. | ||
@@ -892,6 +888,3 @@ // Create a new bounds object so we don't affect the map. | ||
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug: | ||
var mapBounds = | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
map.getZoom() > 3 | ||
var mapBounds = zoom > 3 | ||
? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast()) | ||
@@ -898,0 +891,0 @@ : new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625)); |
@@ -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)};function i(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)}var s=function(t){function e(i,s){var r=t.call(this)||this;return i.getClusterer().extend(e,google.maps.OverlayView),r.cluster=i,r.clusterClassName=r.cluster.getClusterer().getClusterClass(),r.className=r.clusterClassName,r.styles=s,r.center=void 0,r.div=null,r.sums=null,r.visible=!1,r.boundsChangedListener=null,r.url="",r.height=0,r.width=0,r.anchorText=[0,0],r.anchorIcon=[0,0],r.textColor="black",r.textSize=11,r.textDecoration="none",r.fontWeight="bold",r.fontStyle="normal",r.fontFamily="Arial,sans-serif",r.backgroundPosition="0 0",r.cMouseDownInCluster=null,r.cDraggingMapByCluster=null,r.timeOut=null,r.setMap(i.getMap()),r}return i(e,t),e.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},e.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},e.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();e.getMap().fitBounds(s),this.timeOut=window.setTimeout((function(){e.getMap().fitBounds(s),null!==i&&e.getMap().getZoom()>i&&e.getMap().setZoom(i+1)}),100)}t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation()}},e.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},e.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},e.prototype.onAdd=function(){this.div=document.createElement("div"),this.div.className=this.className,this.visible&&this.show(),this.getPanes().overlayMouseTarget.appendChild(this.div),this.boundsChangedListener=google.maps.event.addListener(this.getMap(),"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)},e.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)},e.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"}},e.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},e.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},e.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"},e.prototype.setCenter=function(t){this.center=t},e.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},e}(google.maps.OverlayView),r=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 s(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){if(this.isMarkerAlreadyAdded(t))return!1;var e;if(this.center){if(this.averageCenter&&(e=t.getPosition())){var i=this.markers.length+1;this.center=new google.maps.LatLng((this.center.lat()*(i-1)+e.lat())/i,(this.center.lng()*(i-1)+e.lng())/i),this.calculateBounds()}}else(e=t.getPosition())&&(this.center=e,this.calculateBounds());t.isAdded=!0,this.markers.push(t);var s=this.markers.length,r=this.markerClusterer.getMaxZoom(),o=this.map.getZoom();if(null!==r&&void 0!==o&&o>r)t.getMap()!==this.map&&t.setMap(this.map);else if(s<this.minClusterSize)t.getMap()!==this.map&&t.setMap(this.map);else if(s===this.minClusterSize)for(var n=0;n<s;n++)this.markers[n].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=this.markers.length,e=this.markerClusterer.getMaxZoom(),i=this.map.getZoom();null!==e&&void 0!==i&&i>e||t<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}(),o=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},n=[53,56,66,78,90],a=function(t){function e(i,s,r){void 0===s&&(s=[]),void 0===r&&(r={});var a=t.call(this)||this;return a.extend(e,google.maps.OverlayView),a.markers=[],a.clusters=[],a.listeners=[],a.activeMap=null,a.ready=!1,a.gridSize=r.gridSize||60,a.minClusterSize=r.minimumClusterSize||2,a.maxZoom=r.maxZoom||null,a.styles=r.styles||[],a.title=r.title||"",a.zoomOnClick=!0,void 0!==r.zoomOnClick&&(a.zoomOnClick=r.zoomOnClick),a.averageCenter=!1,void 0!==r.averageCenter&&(a.averageCenter=r.averageCenter),a.ignoreHidden=!1,void 0!==r.ignoreHidden&&(a.ignoreHidden=r.ignoreHidden),a.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(a.enableRetinaIcons=r.enableRetinaIcons),a.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",a.imageExtension=r.imageExtension||"png",a.imageSizes=r.imageSizes||n,a.calculator=r.calculator||o,a.batchSize=r.batchSize||2e3,a.batchSizeIE=r.batchSizeIE||500,a.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(a.batchSize=a.batchSizeIE),a.timerRefStatic=null,a.setupStyles(),a.addMarkers(s,!0),a.setMap(i),a}return i(e,t),e.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")},e.prototype.onIdle=function(){this.redraw()},e.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)])},e.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},e.prototype.draw=function(){},e.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]})},e.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)}this.getMap().fitBounds(e)},e.prototype.getGridSize=function(){return this.gridSize},e.prototype.setGridSize=function(t){this.gridSize=t},e.prototype.getMinimumClusterSize=function(){return this.minClusterSize},e.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},e.prototype.getMaxZoom=function(){return this.maxZoom},e.prototype.setMaxZoom=function(t){this.maxZoom=t},e.prototype.getStyles=function(){return this.styles},e.prototype.setStyles=function(t){this.styles=t},e.prototype.getTitle=function(){return this.title},e.prototype.setTitle=function(t){this.title=t},e.prototype.getZoomOnClick=function(){return this.zoomOnClick},e.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},e.prototype.getAverageCenter=function(){return this.averageCenter},e.prototype.setAverageCenter=function(t){this.averageCenter=t},e.prototype.getIgnoreHidden=function(){return this.ignoreHidden},e.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},e.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},e.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},e.prototype.getImageExtension=function(){return this.imageExtension},e.prototype.setImageExtension=function(t){this.imageExtension=t},e.prototype.getImagePath=function(){return this.imagePath},e.prototype.setImagePath=function(t){this.imagePath=t},e.prototype.getImageSizes=function(){return this.imageSizes},e.prototype.setImageSizes=function(t){this.imageSizes=t},e.prototype.getCalculator=function(){return this.calculator},e.prototype.setCalculator=function(t){this.calculator=t},e.prototype.getBatchSizeIE=function(){return this.batchSizeIE},e.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},e.prototype.getClusterClass=function(){return this.clusterClass},e.prototype.setClusterClass=function(t){this.clusterClass=t},e.prototype.getMarkers=function(){return this.markers},e.prototype.getTotalMarkers=function(){return this.markers.length},e.prototype.getClusters=function(){return this.clusters},e.prototype.getTotalClusters=function(){return this.clusters.length},e.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},e.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},e.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)},e.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)},e.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},e.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},e.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},e.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)},e.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},e.prototype.redraw=function(){this.createClusters(0)},e.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)}},e.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},e.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},e.prototype.addToClosestCluster=function(t){for(var e,i=4e4,s=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<i&&(i=l,s=e)}}s&&s.isMarkerInClusterBounds(t)?s.addMarker(t):((e=new r(this)).addMarker(t),this.clusters.push(e))},e.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=i.getZoom()>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()}}},e.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])},e}(google.maps.OverlayView);t.Cluster=r,t.ClusterIcon=s,t.Clusterer=a,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(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)};function i(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)}var s=function(t){function e(i,s){var r=t.call(this)||this;return i.getClusterer().extend(e,google.maps.OverlayView),r.cluster=i,r.clusterClassName=r.cluster.getClusterer().getClusterClass(),r.className=r.clusterClassName,r.styles=s,r.center=void 0,r.div=null,r.sums=null,r.visible=!1,r.boundsChangedListener=null,r.url="",r.height=0,r.width=0,r.anchorText=[0,0],r.anchorIcon=[0,0],r.textColor="black",r.textSize=11,r.textDecoration="none",r.fontWeight="bold",r.fontStyle="normal",r.fontFamily="Arial,sans-serif",r.backgroundPosition="0 0",r.cMouseDownInCluster=null,r.cDraggingMapByCluster=null,r.timeOut=null,r.setMap(i.getMap()),r}return i(e,t),e.prototype.onBoundsChanged=function(){this.cDraggingMapByCluster=this.cMouseDownInCluster},e.prototype.onMouseDown=function(){this.cMouseDownInCluster=!0,this.cDraggingMapByCluster=!1},e.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()}},e.prototype.onMouseOver=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseover",this.cluster)},e.prototype.onMouseOut=function(){google.maps.event.trigger(this.cluster.getClusterer(),"mouseout",this.cluster)},e.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))},e.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)},e.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"}},e.prototype.hide=function(){this.div&&(this.div.style.display="none"),this.visible=!1},e.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},e.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"},e.prototype.setCenter=function(t){this.center=t},e.prototype.getPosFromLatLng=function(t){var e=this.getProjection().fromLatLngToDivPixel(t);return null!==e&&(e.x-=this.anchorIcon[1],e.y-=this.anchorIcon[0]),e},e}(google.maps.OverlayView),r=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 s(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}(),n=function(t,e){var i=t.length,s=i.toString().length,r=Math.min(s,e);return{text:i.toString(),index:r,title:""}},o=[53,56,66,78,90],a=function(t){function e(i,s,r){void 0===s&&(s=[]),void 0===r&&(r={});var a=t.call(this)||this;return a.extend(e,google.maps.OverlayView),a.markers=[],a.clusters=[],a.listeners=[],a.activeMap=null,a.ready=!1,a.gridSize=r.gridSize||60,a.minClusterSize=r.minimumClusterSize||2,a.maxZoom=r.maxZoom||null,a.styles=r.styles||[],a.title=r.title||"",a.zoomOnClick=!0,void 0!==r.zoomOnClick&&(a.zoomOnClick=r.zoomOnClick),a.averageCenter=!1,void 0!==r.averageCenter&&(a.averageCenter=r.averageCenter),a.ignoreHidden=!1,void 0!==r.ignoreHidden&&(a.ignoreHidden=r.ignoreHidden),a.enableRetinaIcons=!1,void 0!==r.enableRetinaIcons&&(a.enableRetinaIcons=r.enableRetinaIcons),a.imagePath=r.imagePath||"https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",a.imageExtension=r.imageExtension||"png",a.imageSizes=r.imageSizes||o,a.calculator=r.calculator||n,a.batchSize=r.batchSize||2e3,a.batchSizeIE=r.batchSizeIE||500,a.clusterClass=r.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(a.batchSize=a.batchSizeIE),a.timerRefStatic=null,a.setupStyles(),a.addMarkers(s,!0),a.setMap(i),a}return i(e,t),e.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")},e.prototype.onIdle=function(){this.redraw()},e.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)])},e.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},e.prototype.draw=function(){},e.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]})},e.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)},e.prototype.getGridSize=function(){return this.gridSize},e.prototype.setGridSize=function(t){this.gridSize=t},e.prototype.getMinimumClusterSize=function(){return this.minClusterSize},e.prototype.setMinimumClusterSize=function(t){this.minClusterSize=t},e.prototype.getMaxZoom=function(){return this.maxZoom},e.prototype.setMaxZoom=function(t){this.maxZoom=t},e.prototype.getStyles=function(){return this.styles},e.prototype.setStyles=function(t){this.styles=t},e.prototype.getTitle=function(){return this.title},e.prototype.setTitle=function(t){this.title=t},e.prototype.getZoomOnClick=function(){return this.zoomOnClick},e.prototype.setZoomOnClick=function(t){this.zoomOnClick=t},e.prototype.getAverageCenter=function(){return this.averageCenter},e.prototype.setAverageCenter=function(t){this.averageCenter=t},e.prototype.getIgnoreHidden=function(){return this.ignoreHidden},e.prototype.setIgnoreHidden=function(t){this.ignoreHidden=t},e.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons},e.prototype.setEnableRetinaIcons=function(t){this.enableRetinaIcons=t},e.prototype.getImageExtension=function(){return this.imageExtension},e.prototype.setImageExtension=function(t){this.imageExtension=t},e.prototype.getImagePath=function(){return this.imagePath},e.prototype.setImagePath=function(t){this.imagePath=t},e.prototype.getImageSizes=function(){return this.imageSizes},e.prototype.setImageSizes=function(t){this.imageSizes=t},e.prototype.getCalculator=function(){return this.calculator},e.prototype.setCalculator=function(t){this.calculator=t},e.prototype.getBatchSizeIE=function(){return this.batchSizeIE},e.prototype.setBatchSizeIE=function(t){this.batchSizeIE=t},e.prototype.getClusterClass=function(){return this.clusterClass},e.prototype.setClusterClass=function(t){this.clusterClass=t},e.prototype.getMarkers=function(){return this.markers},e.prototype.getTotalMarkers=function(){return this.markers.length},e.prototype.getClusters=function(){return this.clusters},e.prototype.getTotalClusters=function(){return this.clusters.length},e.prototype.addMarker=function(t,e){this.pushMarkerTo(t),e||this.redraw()},e.prototype.addMarkers=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.pushMarkerTo(t[i]);e||this.redraw()},e.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)},e.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)},e.prototype.removeMarker=function(t,e){var i=this.removeMarker_(t);return!e&&i&&this.repaint(),i},e.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},e.prototype.clearMarkers=function(){this.resetViewport(!0),this.markers=[]},e.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)},e.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},e.prototype.redraw=function(){this.createClusters(0)},e.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)}},e.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},e.prototype.isMarkerInBounds=function(t,e){var i=t.getPosition();return!!i&&e.contains(i)},e.prototype.addToClosestCluster=function(t){for(var e,i=4e4,s=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<i&&(i=l,s=e)}}s&&s.isMarkerInClusterBounds(t)?s.addMarker(t):((e=new r(this)).addMarker(t),this.clusters.push(e))},e.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()}}},e.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])},e}(google.maps.OverlayView);t.Cluster=r,t.ClusterIcon=s,t.Clusterer=a,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=umd.min.js.map |
{ | ||
"name": "@react-google-maps/marker-clusterer", | ||
"sideEffects": false, | ||
"version": "2.11.0", | ||
"version": "2.11.1", | ||
"description": "Marker Clusterer for React.js Google Maps API", | ||
@@ -64,3 +64,3 @@ "license": "MIT", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.73.0", | ||
"rollup": "2.74.1", | ||
"rollup-plugin-dts": "4.2.1", | ||
@@ -67,0 +67,0 @@ "rollup-plugin-terser": "7.0.2" |
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
657641
4271