Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google/markerclusterer

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google/markerclusterer - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [2.0.4](https://github.com/googlemaps/v3-utility-library/compare/@google/markerclusterer@2.0.3...@google/markerclusterer@2.0.4) (2019-12-09)
### Bug Fixes
* transpile code for iife and umd outputs ([#586](https://github.com/googlemaps/v3-utility-library/issues/586)) ([fb9ad06](https://github.com/googlemaps/v3-utility-library/commit/fb9ad066cbf5d87cffcda2c435196ad20fed56f1))
# 2.0.0-alpha.2 (2019-10-04)

@@ -8,0 +19,0 @@

2

dist/markerclusterer.min.js

@@ -1,1 +0,1 @@

var MarkerClusterer=function(){"use strict";class t{constructor(e,s,i){this.extend(t,google.maps.OverlayView),this.map_=e,this.MARKER_CLUSTER_IMAGE_PATH_="../images/m",this.MARKER_CLUSTER_IMAGE_EXTENSION_="png",this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var r=i||{};this.zIndex_=r.zIndex||google.maps.Marker.MAX_ZINDEX+1,this.gridSize_=r.gridSize||60,this.minClusterSize_=r.minimumClusterSize||2,this.maxZoom_=r.maxZoom||null,this.styles_=r.styles||[],this.imagePath_=r.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=r.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=r.zoomOnClick&&(this.zoomOnClick_=r.zoomOnClick),this.averageCenter_=!1,null!=r.averageCenter&&(this.averageCenter_=r.averageCenter),this.setupStyles_(),this.setMap(e),this.prevZoom_=this.map_.getZoom();var h=this;google.maps.event.addListener(this.map_,"zoom_changed",(function(){var t=h.map_.getZoom(),e=h.map_.minZoom||0,s=Math.min(h.map_.maxZoom||100,h.map_.mapTypes[h.map_.getMapTypeId()].maxZoom);t=Math.min(Math.max(t,e),s),h.prevZoom_!=t&&(h.prevZoom_=t,h.resetViewport())})),google.maps.event.addListener(this.map_,"idle",(function(){h.redraw()})),s&&(s.length||Object.keys(s).length)&&this.addMarkers(s,!1)}extend(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])}onAdd(){this.setReady_(!0)}draw(){}setupStyles_(){if(!this.styles_.length)for(var t,e=0;t=this.sizes[e];e++)this.styles_.push({url:this.imagePath_+(e+1)+"."+this.imageExtension_,height:t,width:t})}fitMapToMarkers(){for(var t,e=this.getMarkers(),s=new google.maps.LatLngBounds,i=0;t=e[i];i++)s.extend(t.getPosition());this.map_.fitBounds(s)}setZIndex(t){this.zIndex_=t}getZIndex(){return this.zIndex_}setStyles(t){this.styles_=t}getStyles(){return this.styles_}isZoomOnClick(){return this.zoomOnClick_}isAverageCenter(){return this.averageCenter_}getMarkers(){return this.markers_}getTotalMarkers(){return this.markers_.length}setMaxZoom(t){this.maxZoom_=t}getMaxZoom(){return this.maxZoom_}calculator_(t,e){for(var s=0,i=t.length,r=i;0!==r;)r=parseInt(r/10,10),s++;return{text:i,index:s=Math.min(s,e)}}setCalculator(t){this.calculator_=t}getCalculator(){return this.calculator_}addMarkers(t,e){if(t.length)for(let e,s=0;e=t[s];s++)this.pushMarkerTo_(e);else if(Object.keys(t).length)for(let e in t)this.pushMarkerTo_(t[e]);e||this.redraw()}pushMarkerTo_(t){if(t.isAdded=!1,t.draggable){var e=this;google.maps.event.addListener(t,"dragend",(function(){t.isAdded=!1,e.repaint()}))}this.markers_.push(t)}addMarker(t,e){this.pushMarkerTo_(t),e||this.redraw()}removeMarker_(t){var e=-1;if(this.markers_.indexOf)e=this.markers_.indexOf(t);else for(var s,i=0;s=this.markers_[i];i++)if(s==t){e=i;break}return-1!=e&&(t.setMap(null),this.markers_.splice(e,1),!0)}removeMarker(t,e){var s=this.removeMarker_(t);return!(e||!s)&&(this.resetViewport(),this.redraw(),!0)}removeMarkers(t,e){for(var s,i=t===this.getMarkers()?t.slice():t,r=!1,h=0;s=i[h];h++){var a=this.removeMarker_(s);r=r||a}if(!e&&r)return this.resetViewport(),this.redraw(),!0}setReady_(t){this.ready_||(this.ready_=t,this.createClusters_())}getTotalClusters(){return this.clusters_.length}getMap(){return this.map_}setMap(t){this.map_=t}getGridSize(){return this.gridSize_}setGridSize(t){this.gridSize_=t}getMinClusterSize(){return this.minClusterSize_}setMinClusterSize(t){this.minClusterSize_=t}getExtendedBounds(t){var e=this.getProjection(),s=new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()),i=new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()),r=e.fromLatLngToDivPixel(s);r.x+=this.gridSize_,r.y-=this.gridSize_;var h=e.fromLatLngToDivPixel(i);h.x-=this.gridSize_,h.y+=this.gridSize_;var a=e.fromDivPixelToLatLng(r),n=e.fromDivPixelToLatLng(h);return t.extend(a),t.extend(n),t}isMarkerInBounds_(t,e){return e.contains(t.getPosition())}clearMarkers(){this.resetViewport(!0),this.markers_=[]}resetViewport(t){for(let t,e=0;t=this.clusters_[e];e++)t.remove();for(let e,s=0;e=this.markers_[s];s++)e.isAdded=!1,t&&e.setMap(null);this.clusters_=[]}repaint(){var t=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),setTimeout((function(){for(var e,s=0;e=t[s];s++)e.remove()}),0)}redraw(){this.createClusters_()}distanceBetweenPoints_(t,e){if(!t||!e)return 0;var s=(e.lat()-t.lat())*Math.PI/180,i=(e.lng()-t.lng())*Math.PI/180,r=Math.sin(s/2)*Math.sin(s/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(i/2)*Math.sin(i/2);return 6371*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}addToClosestCluster_(t){for(var s,i=4e4,r=null,h=0;s=this.clusters_[h];h++){var a=s.getCenter();if(a){var n=this.distanceBetweenPoints_(a,t.getPosition());n<i&&(i=n,r=s)}}if(r&&r.isMarkerInClusterBounds(t))r.addMarker(t);else{var o=new e(this);o.addMarker(t),this.clusters_.push(o)}}createClusters_(){if(this.ready_)for(var t,e=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),s=this.getExtendedBounds(e),i=0;t=this.markers_[i];i++)!t.isAdded&&this.isMarkerInBounds_(t,s)&&this.addToClosestCluster_(t)}}class e{constructor(t){this.markerClusterer_=t,this.map_=t.getMap(),this.gridSize_=t.getGridSize(),this.minClusterSize_=t.getMinClusterSize(),this.averageCenter_=t.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new s(this,t.getStyles(),t.getGridSize())}isMarkerAlreadyAdded(t){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(t);for(var e,s=0;e=this.markers_[s];s++)if(e==t)return!0;return!1}addMarker(t){if(this.isMarkerAlreadyAdded(t))return!1;if(this.center_){if(this.averageCenter_){var e=this.markers_.length+1,s=(this.center_.lat()*(e-1)+t.getPosition().lat())/e,i=(this.center_.lng()*(e-1)+t.getPosition().lng())/e;this.center_=new google.maps.LatLng(s,i),this.calculateBounds_()}}else this.center_=t.getPosition(),this.calculateBounds_();t.isAdded=!0,this.markers_.push(t);var r=this.markers_.length;if(r<this.minClusterSize_&&t.getMap()!=this.map_&&t.setMap(this.map_),r==this.minClusterSize_)for(var h=0;h<r;h++)this.markers_[h].setMap(null);return r>=this.minClusterSize_&&t.setMap(null),this.updateIcon(),!0}getMarkerClusterer(){return this.markerClusterer_}getBounds(){for(var t,e=new google.maps.LatLngBounds(this.center_,this.center_),s=this.getMarkers(),i=0;t=s[i];i++)e.extend(t.getPosition());return e}remove(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_}getSize(){return this.markers_.length}getMarkers(){return this.markers_}getCenter(){return this.center_}calculateBounds_(){var t=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(t)}isMarkerInClusterBounds(t){return this.bounds_.contains(t.getPosition())}getMap(){return this.map_}updateIcon(){var t=this.map_.getZoom(),e=this.markerClusterer_.getMaxZoom();if(e&&t>e)for(var s,i=0;s=this.markers_[i];i++)s.setMap(this.map_);else if(this.markers_.length<this.minClusterSize_)this.clusterIcon_.hide();else{var r=this.markerClusterer_.getStyles().length,h=this.markerClusterer_.getCalculator()(this.markers_,r);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(h),this.clusterIcon_.show()}}}class s{constructor(t,e,i){t.getMarkerClusterer().extend(s,google.maps.OverlayView),this.styles_=e,this.padding_=i||0,this.cluster_=t,this.center_=null,this.map_=t.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}triggerClusterClick(){var t=this.cluster_.getBounds(),e=this.cluster_.getMarkerClusterer();google.maps.event.trigger(e.map_,"clusterclick",this.cluster_),e.isZoomOnClick()&&(this.map_.fitBounds(t),this.map_.setCenter(t.getCenter()))}onAdd(){if(this.div_=document.createElement("DIV"),this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.innerHTML=this.sums_.text}this.getPanes().overlayMouseTarget.appendChild(this.div_);var e=this;google.maps.event.addDomListener(this.div_,"click",(function(){e.triggerClusterClick()}))}getPosFromLatLng_(t){var e=this.getProjection().fromLatLngToDivPixel(t);return e.x-=parseInt(this.width_/2,10),e.y-=parseInt(this.height_/2,10),e}draw(){if(this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.top=t.y+"px",this.div_.style.left=t.x+"px"}}hide(){this.div_&&(this.div_.style.display="none"),this.visible_=!1}show(){if(this.div_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.style.display=""}this.visible_=!0}remove(){this.setMap(null)}onRemove(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)}setSums(t){this.sums_=t,this.text_=t.text,this.index_=t.index,this.div_&&(this.div_.innerHTML=t.text),this.useStyle()}useStyle(){var t=Math.max(0,this.sums_.index-1);t=Math.min(this.styles_.length-1,t);var e=this.styles_[t];this.url_=e.url,this.height_=e.height,this.width_=e.width,this.textColor_=e.textColor,this.anchor_=e.anchor,this.textSize_=e.textSize,this.backgroundPosition_=e.backgroundPosition}setCenter(t){this.center_=t}createCss(t){var e=[];e.push("z-index:"+this.cluster_.markerClusterer_.getZIndex()+";"),e.push("background-image:url("+this.url_+");");var s=this.backgroundPosition_?this.backgroundPosition_:"0 0";e.push("background-position:"+s+";"),"object"==typeof this.anchor_?("number"==typeof this.anchor_[0]&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?e.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),"number"==typeof this.anchor_[1]&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?e.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):e.push("width:"+this.width_+"px; text-align:center;")):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;");var i=this.textColor_?this.textColor_:"black",r=this.textSize_?this.textSize_:11;return e.push("cursor:pointer; top:"+t.y+"px; left:"+t.x+"px; color:"+i+"; position:absolute; font-size:"+r+"px; font-family:Arial,sans-serif; font-weight:bold"),e.join("")}}return t}();
var MarkerClusterer=function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function s(e,t,s){return t&&i(e.prototype,t),s&&i(e,s),e}var r=function(){function e(i,s,r){t(this,e),this.extend(e,google.maps.OverlayView),this.map_=i,this.MARKER_CLUSTER_IMAGE_PATH_="../images/m",this.MARKER_CLUSTER_IMAGE_EXTENSION_="png",this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var n=r||{};this.zIndex_=n.zIndex||google.maps.Marker.MAX_ZINDEX+1,this.gridSize_=n.gridSize||60,this.minClusterSize_=n.minimumClusterSize||2,this.maxZoom_=n.maxZoom||null,this.styles_=n.styles||[],this.imagePath_=n.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=n.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=n.zoomOnClick&&(this.zoomOnClick_=n.zoomOnClick),this.averageCenter_=!1,null!=n.averageCenter&&(this.averageCenter_=n.averageCenter),this.setupStyles_(),this.setMap(i),this.prevZoom_=this.map_.getZoom();var a=this;google.maps.event.addListener(this.map_,"zoom_changed",(function(){var e=a.map_.getZoom(),t=a.map_.minZoom||0,i=Math.min(a.map_.maxZoom||100,a.map_.mapTypes[a.map_.getMapTypeId()].maxZoom);e=Math.min(Math.max(e,t),i),a.prevZoom_!=e&&(a.prevZoom_=e,a.resetViewport())})),google.maps.event.addListener(this.map_,"idle",(function(){a.redraw()})),s&&(s.length||Object.keys(s).length)&&this.addMarkers(s,!1)}return s(e,[{key:"extend",value:function(e,t){return function(e){for(var t in e.prototype)this.prototype[t]=e.prototype[t];return this}.apply(e,[t])}},{key:"onAdd",value:function(){this.setReady_(!0)}},{key:"draw",value:function(){}},{key:"setupStyles_",value:function(){if(!this.styles_.length)for(var e,t=0;e=this.sizes[t];t++)this.styles_.push({url:this.imagePath_+(t+1)+"."+this.imageExtension_,height:e,width:e})}},{key:"fitMapToMarkers",value:function(){for(var e,t=this.getMarkers(),i=new google.maps.LatLngBounds,s=0;e=t[s];s++)i.extend(e.getPosition());this.map_.fitBounds(i)}},{key:"setZIndex",value:function(e){this.zIndex_=e}},{key:"getZIndex",value:function(){return this.zIndex_}},{key:"setStyles",value:function(e){this.styles_=e}},{key:"getStyles",value:function(){return this.styles_}},{key:"isZoomOnClick",value:function(){return this.zoomOnClick_}},{key:"isAverageCenter",value:function(){return this.averageCenter_}},{key:"getMarkers",value:function(){return this.markers_}},{key:"getTotalMarkers",value:function(){return this.markers_.length}},{key:"setMaxZoom",value:function(e){this.maxZoom_=e}},{key:"getMaxZoom",value:function(){return this.maxZoom_}},{key:"calculator_",value:function(e,t){for(var i=0,s=e.length,r=s;0!==r;)r=parseInt(r/10,10),i++;return{text:s,index:i=Math.min(i,t)}}},{key:"setCalculator",value:function(e){this.calculator_=e}},{key:"getCalculator",value:function(){return this.calculator_}},{key:"addMarkers",value:function(e,t){if(e.length)for(var i,s=0;i=e[s];s++)this.pushMarkerTo_(i);else if(Object.keys(e).length)for(var r in e)this.pushMarkerTo_(e[r]);t||this.redraw()}},{key:"pushMarkerTo_",value:function(e){if(e.isAdded=!1,e.draggable){var t=this;google.maps.event.addListener(e,"dragend",(function(){e.isAdded=!1,t.repaint()}))}this.markers_.push(e)}},{key:"addMarker",value:function(e,t){this.pushMarkerTo_(e),t||this.redraw()}},{key:"removeMarker_",value:function(e){var t=-1;if(this.markers_.indexOf)t=this.markers_.indexOf(e);else for(var i,s=0;i=this.markers_[s];s++)if(i==e){t=s;break}return-1!=t&&(e.setMap(null),this.markers_.splice(t,1),!0)}},{key:"removeMarker",value:function(e,t){var i=this.removeMarker_(e);return!(t||!i)&&(this.resetViewport(),this.redraw(),!0)}},{key:"removeMarkers",value:function(e,t){for(var i,s=e===this.getMarkers()?e.slice():e,r=!1,n=0;i=s[n];n++){var a=this.removeMarker_(i);r=r||a}if(!t&&r)return this.resetViewport(),this.redraw(),!0}},{key:"setReady_",value:function(e){this.ready_||(this.ready_=e,this.createClusters_())}},{key:"getTotalClusters",value:function(){return this.clusters_.length}},{key:"getMap",value:function(){return this.map_}},{key:"setMap",value:function(e){this.map_=e}},{key:"getGridSize",value:function(){return this.gridSize_}},{key:"setGridSize",value:function(e){this.gridSize_=e}},{key:"getMinClusterSize",value:function(){return this.minClusterSize_}},{key:"setMinClusterSize",value:function(e){this.minClusterSize_=e}},{key:"getExtendedBounds",value:function(e){var t=this.getProjection(),i=new google.maps.LatLng(e.getNorthEast().lat(),e.getNorthEast().lng()),s=new google.maps.LatLng(e.getSouthWest().lat(),e.getSouthWest().lng()),r=t.fromLatLngToDivPixel(i);r.x+=this.gridSize_,r.y-=this.gridSize_;var n=t.fromLatLngToDivPixel(s);n.x-=this.gridSize_,n.y+=this.gridSize_;var a=t.fromDivPixelToLatLng(r),o=t.fromDivPixelToLatLng(n);return e.extend(a),e.extend(o),e}},{key:"isMarkerInBounds_",value:function(e,t){return t.contains(e.getPosition())}},{key:"clearMarkers",value:function(){this.resetViewport(!0),this.markers_=[]}},{key:"resetViewport",value:function(e){for(var t,i=0;t=this.clusters_[i];i++)t.remove();for(var s,r=0;s=this.markers_[r];r++)s.isAdded=!1,e&&s.setMap(null);this.clusters_=[]}},{key:"repaint",value:function(){var e=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),setTimeout((function(){for(var t,i=0;t=e[i];i++)t.remove()}),0)}},{key:"redraw",value:function(){this.createClusters_()}},{key:"distanceBetweenPoints_",value:function(e,t){if(!e||!t)return 0;var i=(t.lat()-e.lat())*Math.PI/180,s=(t.lng()-e.lng())*Math.PI/180,r=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}},{key:"addToClosestCluster_",value:function(e){for(var t,i=4e4,s=null,r=0;t=this.clusters_[r];r++){var a=t.getCenter();if(a){var o=this.distanceBetweenPoints_(a,e.getPosition());o<i&&(i=o,s=t)}}if(s&&s.isMarkerInClusterBounds(e))s.addMarker(e);else{var h=new n(this);h.addMarker(e),this.clusters_.push(h)}}},{key:"createClusters_",value:function(){if(this.ready_)for(var e,t=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),i=this.getExtendedBounds(t),s=0;e=this.markers_[s];s++)!e.isAdded&&this.isMarkerInBounds_(e,i)&&this.addToClosestCluster_(e)}}]),e}(),n=function(){function e(i){t(this,e),this.markerClusterer_=i,this.map_=i.getMap(),this.gridSize_=i.getGridSize(),this.minClusterSize_=i.getMinClusterSize(),this.averageCenter_=i.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new a(this,i.getStyles(),i.getGridSize())}return s(e,[{key:"isMarkerAlreadyAdded",value:function(e){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(e);for(var t,i=0;t=this.markers_[i];i++)if(t==e)return!0;return!1}},{key:"addMarker",value:function(e){if(this.isMarkerAlreadyAdded(e))return!1;if(this.center_){if(this.averageCenter_){var t=this.markers_.length+1,i=(this.center_.lat()*(t-1)+e.getPosition().lat())/t,s=(this.center_.lng()*(t-1)+e.getPosition().lng())/t;this.center_=new google.maps.LatLng(i,s),this.calculateBounds_()}}else this.center_=e.getPosition(),this.calculateBounds_();e.isAdded=!0,this.markers_.push(e);var r=this.markers_.length;if(r<this.minClusterSize_&&e.getMap()!=this.map_&&e.setMap(this.map_),r==this.minClusterSize_)for(var n=0;n<r;n++)this.markers_[n].setMap(null);return r>=this.minClusterSize_&&e.setMap(null),this.updateIcon(),!0}},{key:"getMarkerClusterer",value:function(){return this.markerClusterer_}},{key:"getBounds",value:function(){for(var e,t=new google.maps.LatLngBounds(this.center_,this.center_),i=this.getMarkers(),s=0;e=i[s];s++)t.extend(e.getPosition());return t}},{key:"remove",value:function(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_}},{key:"getSize",value:function(){return this.markers_.length}},{key:"getMarkers",value:function(){return this.markers_}},{key:"getCenter",value:function(){return this.center_}},{key:"calculateBounds_",value:function(){var e=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(e)}},{key:"isMarkerInClusterBounds",value:function(e){return this.bounds_.contains(e.getPosition())}},{key:"getMap",value:function(){return this.map_}},{key:"updateIcon",value:function(){var e=this.map_.getZoom(),t=this.markerClusterer_.getMaxZoom();if(t&&e>t)for(var i,s=0;i=this.markers_[s];s++)i.setMap(this.map_);else if(this.markers_.length<this.minClusterSize_)this.clusterIcon_.hide();else{var r=this.markerClusterer_.getStyles().length,n=this.markerClusterer_.getCalculator()(this.markers_,r);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(n),this.clusterIcon_.show()}}}]),e}(),a=function(){function i(e,s,r){t(this,i),e.getMarkerClusterer().extend(i,google.maps.OverlayView),this.styles_=s,this.padding_=r||0,this.cluster_=e,this.center_=null,this.map_=e.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}return s(i,[{key:"triggerClusterClick",value:function(){var e=this.cluster_.getBounds(),t=this.cluster_.getMarkerClusterer();google.maps.event.trigger(t.map_,"clusterclick",this.cluster_),t.isZoomOnClick()&&(this.map_.fitBounds(e),this.map_.setCenter(e.getCenter()))}},{key:"onAdd",value:function(){if(this.div_=document.createElement("DIV"),this.visible_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(e),this.div_.innerHTML=this.sums_.text}this.getPanes().overlayMouseTarget.appendChild(this.div_);var t=this;google.maps.event.addDomListener(this.div_,"click",(function(){t.triggerClusterClick()}))}},{key:"getPosFromLatLng_",value:function(e){var t=this.getProjection().fromLatLngToDivPixel(e);return t.x-=parseInt(this.width_/2,10),t.y-=parseInt(this.height_/2,10),t}},{key:"draw",value:function(){if(this.visible_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.top=e.y+"px",this.div_.style.left=e.x+"px"}}},{key:"hide",value:function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1}},{key:"show",value:function(){if(this.div_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(e),this.div_.style.display=""}this.visible_=!0}},{key:"remove",value:function(){this.setMap(null)}},{key:"onRemove",value:function(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)}},{key:"setSums",value:function(e){this.sums_=e,this.text_=e.text,this.index_=e.index,this.div_&&(this.div_.innerHTML=e.text),this.useStyle()}},{key:"useStyle",value:function(){var e=Math.max(0,this.sums_.index-1);e=Math.min(this.styles_.length-1,e);var t=this.styles_[e];this.url_=t.url,this.height_=t.height,this.width_=t.width,this.textColor_=t.textColor,this.anchor_=t.anchor,this.textSize_=t.textSize,this.backgroundPosition_=t.backgroundPosition}},{key:"setCenter",value:function(e){this.center_=e}},{key:"createCss",value:function(t){var i=[];i.push("z-index:"+this.cluster_.markerClusterer_.getZIndex()+";"),i.push("background-image:url("+this.url_+");");var s=this.backgroundPosition_?this.backgroundPosition_:"0 0";i.push("background-position:"+s+";"),"object"===e(this.anchor_)?("number"==typeof this.anchor_[0]&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?i.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):i.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),"number"==typeof this.anchor_[1]&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?i.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):i.push("width:"+this.width_+"px; text-align:center;")):i.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;");var r=this.textColor_?this.textColor_:"black",n=this.textSize_?this.textSize_:11;return i.push("cursor:pointer; top:"+t.y+"px; left:"+t.x+"px; color:"+r+"; position:absolute; font-size:"+n+"px; font-family:Arial,sans-serif; font-weight:bold"),i.join("")}}]),i}();return r}();

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).MarkerClusterer=e()}(this,(function(){"use strict";class t{constructor(e,s,i){this.extend(t,google.maps.OverlayView),this.map_=e,this.MARKER_CLUSTER_IMAGE_PATH_="../images/m",this.MARKER_CLUSTER_IMAGE_EXTENSION_="png",this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var r=i||{};this.zIndex_=r.zIndex||google.maps.Marker.MAX_ZINDEX+1,this.gridSize_=r.gridSize||60,this.minClusterSize_=r.minimumClusterSize||2,this.maxZoom_=r.maxZoom||null,this.styles_=r.styles||[],this.imagePath_=r.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=r.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=r.zoomOnClick&&(this.zoomOnClick_=r.zoomOnClick),this.averageCenter_=!1,null!=r.averageCenter&&(this.averageCenter_=r.averageCenter),this.setupStyles_(),this.setMap(e),this.prevZoom_=this.map_.getZoom();var h=this;google.maps.event.addListener(this.map_,"zoom_changed",(function(){var t=h.map_.getZoom(),e=h.map_.minZoom||0,s=Math.min(h.map_.maxZoom||100,h.map_.mapTypes[h.map_.getMapTypeId()].maxZoom);t=Math.min(Math.max(t,e),s),h.prevZoom_!=t&&(h.prevZoom_=t,h.resetViewport())})),google.maps.event.addListener(this.map_,"idle",(function(){h.redraw()})),s&&(s.length||Object.keys(s).length)&&this.addMarkers(s,!1)}extend(t,e){return function(t){for(var e in t.prototype)this.prototype[e]=t.prototype[e];return this}.apply(t,[e])}onAdd(){this.setReady_(!0)}draw(){}setupStyles_(){if(!this.styles_.length)for(var t,e=0;t=this.sizes[e];e++)this.styles_.push({url:this.imagePath_+(e+1)+"."+this.imageExtension_,height:t,width:t})}fitMapToMarkers(){for(var t,e=this.getMarkers(),s=new google.maps.LatLngBounds,i=0;t=e[i];i++)s.extend(t.getPosition());this.map_.fitBounds(s)}setZIndex(t){this.zIndex_=t}getZIndex(){return this.zIndex_}setStyles(t){this.styles_=t}getStyles(){return this.styles_}isZoomOnClick(){return this.zoomOnClick_}isAverageCenter(){return this.averageCenter_}getMarkers(){return this.markers_}getTotalMarkers(){return this.markers_.length}setMaxZoom(t){this.maxZoom_=t}getMaxZoom(){return this.maxZoom_}calculator_(t,e){for(var s=0,i=t.length,r=i;0!==r;)r=parseInt(r/10,10),s++;return{text:i,index:s=Math.min(s,e)}}setCalculator(t){this.calculator_=t}getCalculator(){return this.calculator_}addMarkers(t,e){if(t.length)for(let e,s=0;e=t[s];s++)this.pushMarkerTo_(e);else if(Object.keys(t).length)for(let e in t)this.pushMarkerTo_(t[e]);e||this.redraw()}pushMarkerTo_(t){if(t.isAdded=!1,t.draggable){var e=this;google.maps.event.addListener(t,"dragend",(function(){t.isAdded=!1,e.repaint()}))}this.markers_.push(t)}addMarker(t,e){this.pushMarkerTo_(t),e||this.redraw()}removeMarker_(t){var e=-1;if(this.markers_.indexOf)e=this.markers_.indexOf(t);else for(var s,i=0;s=this.markers_[i];i++)if(s==t){e=i;break}return-1!=e&&(t.setMap(null),this.markers_.splice(e,1),!0)}removeMarker(t,e){var s=this.removeMarker_(t);return!(e||!s)&&(this.resetViewport(),this.redraw(),!0)}removeMarkers(t,e){for(var s,i=t===this.getMarkers()?t.slice():t,r=!1,h=0;s=i[h];h++){var a=this.removeMarker_(s);r=r||a}if(!e&&r)return this.resetViewport(),this.redraw(),!0}setReady_(t){this.ready_||(this.ready_=t,this.createClusters_())}getTotalClusters(){return this.clusters_.length}getMap(){return this.map_}setMap(t){this.map_=t}getGridSize(){return this.gridSize_}setGridSize(t){this.gridSize_=t}getMinClusterSize(){return this.minClusterSize_}setMinClusterSize(t){this.minClusterSize_=t}getExtendedBounds(t){var e=this.getProjection(),s=new google.maps.LatLng(t.getNorthEast().lat(),t.getNorthEast().lng()),i=new google.maps.LatLng(t.getSouthWest().lat(),t.getSouthWest().lng()),r=e.fromLatLngToDivPixel(s);r.x+=this.gridSize_,r.y-=this.gridSize_;var h=e.fromLatLngToDivPixel(i);h.x-=this.gridSize_,h.y+=this.gridSize_;var a=e.fromDivPixelToLatLng(r),n=e.fromDivPixelToLatLng(h);return t.extend(a),t.extend(n),t}isMarkerInBounds_(t,e){return e.contains(t.getPosition())}clearMarkers(){this.resetViewport(!0),this.markers_=[]}resetViewport(t){for(let t,e=0;t=this.clusters_[e];e++)t.remove();for(let e,s=0;e=this.markers_[s];s++)e.isAdded=!1,t&&e.setMap(null);this.clusters_=[]}repaint(){var t=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),setTimeout((function(){for(var e,s=0;e=t[s];s++)e.remove()}),0)}redraw(){this.createClusters_()}distanceBetweenPoints_(t,e){if(!t||!e)return 0;var s=(e.lat()-t.lat())*Math.PI/180,i=(e.lng()-t.lng())*Math.PI/180,r=Math.sin(s/2)*Math.sin(s/2)+Math.cos(t.lat()*Math.PI/180)*Math.cos(e.lat()*Math.PI/180)*Math.sin(i/2)*Math.sin(i/2);return 6371*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}addToClosestCluster_(t){for(var s,i=4e4,r=null,h=0;s=this.clusters_[h];h++){var a=s.getCenter();if(a){var n=this.distanceBetweenPoints_(a,t.getPosition());n<i&&(i=n,r=s)}}if(r&&r.isMarkerInClusterBounds(t))r.addMarker(t);else{var o=new e(this);o.addMarker(t),this.clusters_.push(o)}}createClusters_(){if(this.ready_)for(var t,e=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),s=this.getExtendedBounds(e),i=0;t=this.markers_[i];i++)!t.isAdded&&this.isMarkerInBounds_(t,s)&&this.addToClosestCluster_(t)}}class e{constructor(t){this.markerClusterer_=t,this.map_=t.getMap(),this.gridSize_=t.getGridSize(),this.minClusterSize_=t.getMinClusterSize(),this.averageCenter_=t.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new s(this,t.getStyles(),t.getGridSize())}isMarkerAlreadyAdded(t){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(t);for(var e,s=0;e=this.markers_[s];s++)if(e==t)return!0;return!1}addMarker(t){if(this.isMarkerAlreadyAdded(t))return!1;if(this.center_){if(this.averageCenter_){var e=this.markers_.length+1,s=(this.center_.lat()*(e-1)+t.getPosition().lat())/e,i=(this.center_.lng()*(e-1)+t.getPosition().lng())/e;this.center_=new google.maps.LatLng(s,i),this.calculateBounds_()}}else this.center_=t.getPosition(),this.calculateBounds_();t.isAdded=!0,this.markers_.push(t);var r=this.markers_.length;if(r<this.minClusterSize_&&t.getMap()!=this.map_&&t.setMap(this.map_),r==this.minClusterSize_)for(var h=0;h<r;h++)this.markers_[h].setMap(null);return r>=this.minClusterSize_&&t.setMap(null),this.updateIcon(),!0}getMarkerClusterer(){return this.markerClusterer_}getBounds(){for(var t,e=new google.maps.LatLngBounds(this.center_,this.center_),s=this.getMarkers(),i=0;t=s[i];i++)e.extend(t.getPosition());return e}remove(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_}getSize(){return this.markers_.length}getMarkers(){return this.markers_}getCenter(){return this.center_}calculateBounds_(){var t=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(t)}isMarkerInClusterBounds(t){return this.bounds_.contains(t.getPosition())}getMap(){return this.map_}updateIcon(){var t=this.map_.getZoom(),e=this.markerClusterer_.getMaxZoom();if(e&&t>e)for(var s,i=0;s=this.markers_[i];i++)s.setMap(this.map_);else if(this.markers_.length<this.minClusterSize_)this.clusterIcon_.hide();else{var r=this.markerClusterer_.getStyles().length,h=this.markerClusterer_.getCalculator()(this.markers_,r);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(h),this.clusterIcon_.show()}}}class s{constructor(t,e,i){t.getMarkerClusterer().extend(s,google.maps.OverlayView),this.styles_=e,this.padding_=i||0,this.cluster_=t,this.center_=null,this.map_=t.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}triggerClusterClick(){var t=this.cluster_.getBounds(),e=this.cluster_.getMarkerClusterer();google.maps.event.trigger(e.map_,"clusterclick",this.cluster_),e.isZoomOnClick()&&(this.map_.fitBounds(t),this.map_.setCenter(t.getCenter()))}onAdd(){if(this.div_=document.createElement("DIV"),this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.innerHTML=this.sums_.text}this.getPanes().overlayMouseTarget.appendChild(this.div_);var e=this;google.maps.event.addDomListener(this.div_,"click",(function(){e.triggerClusterClick()}))}getPosFromLatLng_(t){var e=this.getProjection().fromLatLngToDivPixel(t);return e.x-=parseInt(this.width_/2,10),e.y-=parseInt(this.height_/2,10),e}draw(){if(this.visible_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.top=t.y+"px",this.div_.style.left=t.x+"px"}}hide(){this.div_&&(this.div_.style.display="none"),this.visible_=!1}show(){if(this.div_){var t=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(t),this.div_.style.display=""}this.visible_=!0}remove(){this.setMap(null)}onRemove(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)}setSums(t){this.sums_=t,this.text_=t.text,this.index_=t.index,this.div_&&(this.div_.innerHTML=t.text),this.useStyle()}useStyle(){var t=Math.max(0,this.sums_.index-1);t=Math.min(this.styles_.length-1,t);var e=this.styles_[t];this.url_=e.url,this.height_=e.height,this.width_=e.width,this.textColor_=e.textColor,this.anchor_=e.anchor,this.textSize_=e.textSize,this.backgroundPosition_=e.backgroundPosition}setCenter(t){this.center_=t}createCss(t){var e=[];e.push("z-index:"+this.cluster_.markerClusterer_.getZIndex()+";"),e.push("background-image:url("+this.url_+");");var s=this.backgroundPosition_?this.backgroundPosition_:"0 0";e.push("background-position:"+s+";"),"object"==typeof this.anchor_?("number"==typeof this.anchor_[0]&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?e.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),"number"==typeof this.anchor_[1]&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?e.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):e.push("width:"+this.width_+"px; text-align:center;")):e.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;");var i=this.textColor_?this.textColor_:"black",r=this.textSize_?this.textSize_:11;return e.push("cursor:pointer; top:"+t.y+"px; left:"+t.x+"px; color:"+i+"; position:absolute; font-size:"+r+"px; font-family:Arial,sans-serif; font-weight:bold"),e.join("")}}return t}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).MarkerClusterer=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function s(e,t,s){return t&&i(e.prototype,t),s&&i(e,s),e}var r=function(){function e(i,s,r){t(this,e),this.extend(e,google.maps.OverlayView),this.map_=i,this.MARKER_CLUSTER_IMAGE_PATH_="../images/m",this.MARKER_CLUSTER_IMAGE_EXTENSION_="png",this.markers_=[],this.clusters_=[],this.sizes=[53,56,66,78,90],this.styles_=[],this.ready_=!1;var n=r||{};this.zIndex_=n.zIndex||google.maps.Marker.MAX_ZINDEX+1,this.gridSize_=n.gridSize||60,this.minClusterSize_=n.minimumClusterSize||2,this.maxZoom_=n.maxZoom||null,this.styles_=n.styles||[],this.imagePath_=n.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_,this.imageExtension_=n.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_,this.zoomOnClick_=!0,null!=n.zoomOnClick&&(this.zoomOnClick_=n.zoomOnClick),this.averageCenter_=!1,null!=n.averageCenter&&(this.averageCenter_=n.averageCenter),this.setupStyles_(),this.setMap(i),this.prevZoom_=this.map_.getZoom();var a=this;google.maps.event.addListener(this.map_,"zoom_changed",(function(){var e=a.map_.getZoom(),t=a.map_.minZoom||0,i=Math.min(a.map_.maxZoom||100,a.map_.mapTypes[a.map_.getMapTypeId()].maxZoom);e=Math.min(Math.max(e,t),i),a.prevZoom_!=e&&(a.prevZoom_=e,a.resetViewport())})),google.maps.event.addListener(this.map_,"idle",(function(){a.redraw()})),s&&(s.length||Object.keys(s).length)&&this.addMarkers(s,!1)}return s(e,[{key:"extend",value:function(e,t){return function(e){for(var t in e.prototype)this.prototype[t]=e.prototype[t];return this}.apply(e,[t])}},{key:"onAdd",value:function(){this.setReady_(!0)}},{key:"draw",value:function(){}},{key:"setupStyles_",value:function(){if(!this.styles_.length)for(var e,t=0;e=this.sizes[t];t++)this.styles_.push({url:this.imagePath_+(t+1)+"."+this.imageExtension_,height:e,width:e})}},{key:"fitMapToMarkers",value:function(){for(var e,t=this.getMarkers(),i=new google.maps.LatLngBounds,s=0;e=t[s];s++)i.extend(e.getPosition());this.map_.fitBounds(i)}},{key:"setZIndex",value:function(e){this.zIndex_=e}},{key:"getZIndex",value:function(){return this.zIndex_}},{key:"setStyles",value:function(e){this.styles_=e}},{key:"getStyles",value:function(){return this.styles_}},{key:"isZoomOnClick",value:function(){return this.zoomOnClick_}},{key:"isAverageCenter",value:function(){return this.averageCenter_}},{key:"getMarkers",value:function(){return this.markers_}},{key:"getTotalMarkers",value:function(){return this.markers_.length}},{key:"setMaxZoom",value:function(e){this.maxZoom_=e}},{key:"getMaxZoom",value:function(){return this.maxZoom_}},{key:"calculator_",value:function(e,t){for(var i=0,s=e.length,r=s;0!==r;)r=parseInt(r/10,10),i++;return{text:s,index:i=Math.min(i,t)}}},{key:"setCalculator",value:function(e){this.calculator_=e}},{key:"getCalculator",value:function(){return this.calculator_}},{key:"addMarkers",value:function(e,t){if(e.length)for(var i,s=0;i=e[s];s++)this.pushMarkerTo_(i);else if(Object.keys(e).length)for(var r in e)this.pushMarkerTo_(e[r]);t||this.redraw()}},{key:"pushMarkerTo_",value:function(e){if(e.isAdded=!1,e.draggable){var t=this;google.maps.event.addListener(e,"dragend",(function(){e.isAdded=!1,t.repaint()}))}this.markers_.push(e)}},{key:"addMarker",value:function(e,t){this.pushMarkerTo_(e),t||this.redraw()}},{key:"removeMarker_",value:function(e){var t=-1;if(this.markers_.indexOf)t=this.markers_.indexOf(e);else for(var i,s=0;i=this.markers_[s];s++)if(i==e){t=s;break}return-1!=t&&(e.setMap(null),this.markers_.splice(t,1),!0)}},{key:"removeMarker",value:function(e,t){var i=this.removeMarker_(e);return!(t||!i)&&(this.resetViewport(),this.redraw(),!0)}},{key:"removeMarkers",value:function(e,t){for(var i,s=e===this.getMarkers()?e.slice():e,r=!1,n=0;i=s[n];n++){var a=this.removeMarker_(i);r=r||a}if(!t&&r)return this.resetViewport(),this.redraw(),!0}},{key:"setReady_",value:function(e){this.ready_||(this.ready_=e,this.createClusters_())}},{key:"getTotalClusters",value:function(){return this.clusters_.length}},{key:"getMap",value:function(){return this.map_}},{key:"setMap",value:function(e){this.map_=e}},{key:"getGridSize",value:function(){return this.gridSize_}},{key:"setGridSize",value:function(e){this.gridSize_=e}},{key:"getMinClusterSize",value:function(){return this.minClusterSize_}},{key:"setMinClusterSize",value:function(e){this.minClusterSize_=e}},{key:"getExtendedBounds",value:function(e){var t=this.getProjection(),i=new google.maps.LatLng(e.getNorthEast().lat(),e.getNorthEast().lng()),s=new google.maps.LatLng(e.getSouthWest().lat(),e.getSouthWest().lng()),r=t.fromLatLngToDivPixel(i);r.x+=this.gridSize_,r.y-=this.gridSize_;var n=t.fromLatLngToDivPixel(s);n.x-=this.gridSize_,n.y+=this.gridSize_;var a=t.fromDivPixelToLatLng(r),o=t.fromDivPixelToLatLng(n);return e.extend(a),e.extend(o),e}},{key:"isMarkerInBounds_",value:function(e,t){return t.contains(e.getPosition())}},{key:"clearMarkers",value:function(){this.resetViewport(!0),this.markers_=[]}},{key:"resetViewport",value:function(e){for(var t,i=0;t=this.clusters_[i];i++)t.remove();for(var s,r=0;s=this.markers_[r];r++)s.isAdded=!1,e&&s.setMap(null);this.clusters_=[]}},{key:"repaint",value:function(){var e=this.clusters_.slice();this.clusters_.length=0,this.resetViewport(),this.redraw(),setTimeout((function(){for(var t,i=0;t=e[i];i++)t.remove()}),0)}},{key:"redraw",value:function(){this.createClusters_()}},{key:"distanceBetweenPoints_",value:function(e,t){if(!e||!t)return 0;var i=(t.lat()-e.lat())*Math.PI/180,s=(t.lng()-e.lng())*Math.PI/180,r=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(s/2)*Math.sin(s/2);return 6371*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}},{key:"addToClosestCluster_",value:function(e){for(var t,i=4e4,s=null,r=0;t=this.clusters_[r];r++){var a=t.getCenter();if(a){var o=this.distanceBetweenPoints_(a,e.getPosition());o<i&&(i=o,s=t)}}if(s&&s.isMarkerInClusterBounds(e))s.addMarker(e);else{var h=new n(this);h.addMarker(e),this.clusters_.push(h)}}},{key:"createClusters_",value:function(){if(this.ready_)for(var e,t=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),i=this.getExtendedBounds(t),s=0;e=this.markers_[s];s++)!e.isAdded&&this.isMarkerInBounds_(e,i)&&this.addToClosestCluster_(e)}}]),e}(),n=function(){function e(i){t(this,e),this.markerClusterer_=i,this.map_=i.getMap(),this.gridSize_=i.getGridSize(),this.minClusterSize_=i.getMinClusterSize(),this.averageCenter_=i.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new a(this,i.getStyles(),i.getGridSize())}return s(e,[{key:"isMarkerAlreadyAdded",value:function(e){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(e);for(var t,i=0;t=this.markers_[i];i++)if(t==e)return!0;return!1}},{key:"addMarker",value:function(e){if(this.isMarkerAlreadyAdded(e))return!1;if(this.center_){if(this.averageCenter_){var t=this.markers_.length+1,i=(this.center_.lat()*(t-1)+e.getPosition().lat())/t,s=(this.center_.lng()*(t-1)+e.getPosition().lng())/t;this.center_=new google.maps.LatLng(i,s),this.calculateBounds_()}}else this.center_=e.getPosition(),this.calculateBounds_();e.isAdded=!0,this.markers_.push(e);var r=this.markers_.length;if(r<this.minClusterSize_&&e.getMap()!=this.map_&&e.setMap(this.map_),r==this.minClusterSize_)for(var n=0;n<r;n++)this.markers_[n].setMap(null);return r>=this.minClusterSize_&&e.setMap(null),this.updateIcon(),!0}},{key:"getMarkerClusterer",value:function(){return this.markerClusterer_}},{key:"getBounds",value:function(){for(var e,t=new google.maps.LatLngBounds(this.center_,this.center_),i=this.getMarkers(),s=0;e=i[s];s++)t.extend(e.getPosition());return t}},{key:"remove",value:function(){this.clusterIcon_.remove(),this.markers_.length=0,delete this.markers_}},{key:"getSize",value:function(){return this.markers_.length}},{key:"getMarkers",value:function(){return this.markers_}},{key:"getCenter",value:function(){return this.center_}},{key:"calculateBounds_",value:function(){var e=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(e)}},{key:"isMarkerInClusterBounds",value:function(e){return this.bounds_.contains(e.getPosition())}},{key:"getMap",value:function(){return this.map_}},{key:"updateIcon",value:function(){var e=this.map_.getZoom(),t=this.markerClusterer_.getMaxZoom();if(t&&e>t)for(var i,s=0;i=this.markers_[s];s++)i.setMap(this.map_);else if(this.markers_.length<this.minClusterSize_)this.clusterIcon_.hide();else{var r=this.markerClusterer_.getStyles().length,n=this.markerClusterer_.getCalculator()(this.markers_,r);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(n),this.clusterIcon_.show()}}}]),e}(),a=function(){function i(e,s,r){t(this,i),e.getMarkerClusterer().extend(i,google.maps.OverlayView),this.styles_=s,this.padding_=r||0,this.cluster_=e,this.center_=null,this.map_=e.getMap(),this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(this.map_)}return s(i,[{key:"triggerClusterClick",value:function(){var e=this.cluster_.getBounds(),t=this.cluster_.getMarkerClusterer();google.maps.event.trigger(t.map_,"clusterclick",this.cluster_),t.isZoomOnClick()&&(this.map_.fitBounds(e),this.map_.setCenter(e.getCenter()))}},{key:"onAdd",value:function(){if(this.div_=document.createElement("DIV"),this.visible_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(e),this.div_.innerHTML=this.sums_.text}this.getPanes().overlayMouseTarget.appendChild(this.div_);var t=this;google.maps.event.addDomListener(this.div_,"click",(function(){t.triggerClusterClick()}))}},{key:"getPosFromLatLng_",value:function(e){var t=this.getProjection().fromLatLngToDivPixel(e);return t.x-=parseInt(this.width_/2,10),t.y-=parseInt(this.height_/2,10),t}},{key:"draw",value:function(){if(this.visible_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.top=e.y+"px",this.div_.style.left=e.x+"px"}}},{key:"hide",value:function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1}},{key:"show",value:function(){if(this.div_){var e=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(e),this.div_.style.display=""}this.visible_=!0}},{key:"remove",value:function(){this.setMap(null)}},{key:"onRemove",value:function(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)}},{key:"setSums",value:function(e){this.sums_=e,this.text_=e.text,this.index_=e.index,this.div_&&(this.div_.innerHTML=e.text),this.useStyle()}},{key:"useStyle",value:function(){var e=Math.max(0,this.sums_.index-1);e=Math.min(this.styles_.length-1,e);var t=this.styles_[e];this.url_=t.url,this.height_=t.height,this.width_=t.width,this.textColor_=t.textColor,this.anchor_=t.anchor,this.textSize_=t.textSize,this.backgroundPosition_=t.backgroundPosition}},{key:"setCenter",value:function(e){this.center_=e}},{key:"createCss",value:function(t){var i=[];i.push("z-index:"+this.cluster_.markerClusterer_.getZIndex()+";"),i.push("background-image:url("+this.url_+");");var s=this.backgroundPosition_?this.backgroundPosition_:"0 0";i.push("background-position:"+s+";"),"object"===e(this.anchor_)?("number"==typeof this.anchor_[0]&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?i.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):i.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),"number"==typeof this.anchor_[1]&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?i.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):i.push("width:"+this.width_+"px; text-align:center;")):i.push("height:"+this.height_+"px; line-height:"+this.height_+"px; width:"+this.width_+"px; text-align:center;");var r=this.textColor_?this.textColor_:"black",n=this.textSize_?this.textSize_:11;return i.push("cursor:pointer; top:"+t.y+"px; left:"+t.x+"px; color:"+r+"; position:absolute; font-size:"+n+"px; font-family:Arial,sans-serif; font-weight:bold"),i.join("")}}]),i}();return r}));
{
"name": "@google/markerclusterer",
"version": "2.0.3",
"version": "2.0.4",
"description": "The library creates and manages per-zoom-level clusters for large amounts of markers.",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc