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.7 to 2.0.8

11

CHANGELOG.md

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

## [2.0.8](https://github.com/googlemaps/v3-utility-library/compare/@google/markerclusterer@2.0.7...@google/markerclusterer@2.0.8) (2020-03-12)
### Bug Fixes
* add polyfills via core-js ([#634](https://github.com/googlemaps/v3-utility-library/issues/634)) ([4699c9a](https://github.com/googlemaps/v3-utility-library/commit/4699c9abf69307829a8782c917f1eb0108ac941b))
## [2.0.7](https://github.com/googlemaps/v3-utility-library/compare/@google/markerclusterer@2.0.6...@google/markerclusterer@2.0.7) (2020-03-12)

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

2

dist/markerclusterer.umd.js

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

!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}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.index-of"),require("core-js/modules/es.array.join"),require("core-js/modules/es.array.slice"),require("core-js/modules/es.array.splice"),require("core-js/modules/es.object.keys"),require("core-js/modules/es.parse-int"),require("core-js/modules/es.string.anchor")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.index-of","core-js/modules/es.array.join","core-js/modules/es.array.slice","core-js/modules/es.array.splice","core-js/modules/es.object.keys","core-js/modules/es.parse-int","core-js/modules/es.string.anchor"],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 s(e,t){for(var s=0;s<t.length;s++){var i=t[s];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function i(e,t,i){return t&&s(e.prototype,t),i&&s(e,i),e}var r=function(){function e(s,i,r){t(this,e),this.extend(e,google.maps.OverlayView),this.map_=s,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(s),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,s=Math.min(a.map_.maxZoom||100,a.map_.mapTypes[a.map_.getMapTypeId()].maxZoom);e=Math.min(Math.max(e,t),s),a.prevZoom_!=e&&(a.prevZoom_=e,a.resetViewport())})),google.maps.event.addListener(this.map_,"idle",(function(){a.redraw()})),i&&(i.length||Object.keys(i).length)&&this.addMarkers(i,!1)}return i(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(),s=new google.maps.LatLngBounds,i=0;e=t[i];i++)s.extend(e.getPosition());this.map_.fitBounds(s)}},{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 s=0,i=e.length,r=i;0!==r;)r=parseInt(r/10,10),s++;return{text:i,index:s=Math.min(s,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 s,i=0;s=e[i];i++)this.pushMarkerTo_(s);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 s,i=0;s=this.markers_[i];i++)if(s==e){t=i;break}return-1!=t&&(e.setMap(null),this.markers_.splice(t,1),!0)}},{key:"removeMarker",value:function(e,t){var s=this.removeMarker_(e);return!(t||!s)&&(this.resetViewport(),this.redraw(),!0)}},{key:"removeMarkers",value:function(e,t){for(var s,i=e===this.getMarkers()?e.slice():e,r=!1,n=0;s=i[n];n++){var a=this.removeMarker_(s);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(),s=new google.maps.LatLng(e.getNorthEast().lat(),e.getNorthEast().lng()),i=new google.maps.LatLng(e.getSouthWest().lat(),e.getSouthWest().lng()),r=t.fromLatLngToDivPixel(s);r.x+=this.gridSize_,r.y-=this.gridSize_;var n=t.fromLatLngToDivPixel(i);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,s=0;t=this.clusters_[s];s++)t.remove();for(var i,r=0;i=this.markers_[r];r++)i.isAdded=!1,e&&i.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,s=0;t=e[s];s++)t.remove()}),0)}},{key:"redraw",value:function(){this.createClusters_()}},{key:"distanceBetweenPoints_",value:function(e,t){if(!e||!t)return 0;var s=(t.lat()-e.lat())*Math.PI/180,i=(t.lng()-e.lng())*Math.PI/180,r=Math.sin(s/2)*Math.sin(s/2)+Math.cos(e.lat()*Math.PI/180)*Math.cos(t.lat()*Math.PI/180)*Math.sin(i/2)*Math.sin(i/2);return 6371*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))}},{key:"addToClosestCluster_",value:function(e){for(var t,s=4e4,i=null,r=0;t=this.clusters_[r];r++){var a=t.getCenter();if(a){var o=this.distanceBetweenPoints_(a,e.getPosition());o<s&&(s=o,i=t)}}if(i&&i.isMarkerInClusterBounds(e))i.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()),s=this.getExtendedBounds(t),i=0;e=this.markers_[i];i++)!e.isAdded&&this.isMarkerInBounds_(e,s)&&this.addToClosestCluster_(e)}}]),e}(),n=function(){function e(s){t(this,e),this.markerClusterer_=s,this.map_=s.getMap(),this.gridSize_=s.getGridSize(),this.minClusterSize_=s.getMinClusterSize(),this.averageCenter_=s.isAverageCenter(),this.center_=null,this.markers_=[],this.bounds_=null,this.clusterIcon_=new a(this,s.getStyles(),s.getGridSize())}return i(e,[{key:"isMarkerAlreadyAdded",value:function(e){if(this.markers_.indexOf)return-1!=this.markers_.indexOf(e);for(var t,s=0;t=this.markers_[s];s++)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,s=(this.center_.lat()*(t-1)+e.getPosition().lat())/t,i=(this.center_.lng()*(t-1)+e.getPosition().lng())/t;this.center_=new google.maps.LatLng(s,i),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_),s=this.getMarkers(),i=0;e=s[i];i++)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 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,n=this.markerClusterer_.getCalculator()(this.markers_,r);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(n),this.clusterIcon_.show()}}}]),e}(),a=function(){function s(e,i,r){t(this,s),e.getMarkerClusterer().extend(s,google.maps.OverlayView),this.styles_=i,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 i(s,[{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 s=[];s.push("z-index:"+this.cluster_.markerClusterer_.getZIndex()+";"),s.push("background-image:url("+this.url_+");");var i=this.backgroundPosition_?this.backgroundPosition_:"0 0";s.push("background-position:"+i+";"),"object"===e(this.anchor_)?("number"==typeof this.anchor_[0]&&this.anchor_[0]>0&&this.anchor_[0]<this.height_?s.push("height:"+(this.height_-this.anchor_[0])+"px; padding-top:"+this.anchor_[0]+"px;"):s.push("height:"+this.height_+"px; line-height:"+this.height_+"px;"),"number"==typeof this.anchor_[1]&&this.anchor_[1]>0&&this.anchor_[1]<this.width_?s.push("width:"+(this.width_-this.anchor_[1])+"px; padding-left:"+this.anchor_[1]+"px;"):s.push("width:"+this.width_+"px; text-align:center;")):s.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 s.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"),s.join("")}}]),s}();return r}));
{
"name": "@google/markerclusterer",
"version": "2.0.7",
"version": "2.0.8",
"description": "The library creates and manages per-zoom-level clusters for large amounts of markers.",

@@ -36,4 +36,3 @@ "keywords": [

"registry": "https://wombat-dressing-room.appspot.com"
},
"browserslist": "> 0.25%, not dead"
}
}
MarkerClusterer for Google Maps v3
==================================
>**Note**: It is recommended to use [@google/markerclustererplus](https://github.com/googlemaps/v3-utility-library/tree/master/packages/markerclustererplus) instead of this package.
## Description

@@ -5,0 +7,0 @@

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