@agm/js-marker-clusterer
Version:
Angular Google Maps (AGM) extension for js-marker-clusterer support
2 lines • 6.99 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@agm/core"),require("rxjs"),require("js-marker-clusterer")):"function"==typeof define&&define.amd?define("@agm/js-marker-clusterer",["exports","@angular/core","@agm/core","rxjs","js-marker-clusterer"],t):t(((e=e||self).ngmaps=e.ngmaps||{},e.ngmaps.jsMarkerClusterer={}),e.ng.core,e.ngmaps.core,e.rxjs)}(this,(function(e,t,r,n){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}var u=function(e){function u(t,r){var n=e.call(this,t,r)||this;return n._mapsWrapper=t,n._zone=r,n._clustererInstance=new Promise((function(e){n._resolver=e})),n}return function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(u,e),u.prototype.init=function(e){var t=this;this._mapsWrapper.getNativeMap().then((function(r){var n=new MarkerClusterer(r,[],e);t._resolver(n)}))},u.prototype.getClustererInstance=function(){return this._clustererInstance},u.prototype.addMarker=function(e){var t=this.getClustererInstance(),r=this._mapsWrapper.createMarker({position:{lat:e.latitude,lng:e.longitude},label:e.label,draggable:e.draggable,icon:e.iconUrl,opacity:e.opacity,visible:e.visible,zIndex:e.zIndex,title:e.title,clickable:e.clickable},!1);Promise.all([t,r]).then((function(e){var t=a(e,2),r=t[0],n=t[1];return r.addMarker(n)})),this._markers.set(e,r)},u.prototype.deleteMarker=function(e){var t=this,r=this._markers.get(e);return null==r?Promise.resolve():r.then((function(r){t._zone.run((function(){r.setMap(null),t.getClustererInstance().then((function(n){n.removeMarker(r),t._markers.delete(e)}))}))}))},u.prototype.clearMarkers=function(){return this.getClustererInstance().then((function(e){e.clearMarkers()}))},u.prototype.setGridSize=function(e){this.getClustererInstance().then((function(t){t.setGridSize(e.gridSize)}))},u.prototype.setMaxZoom=function(e){this.getClustererInstance().then((function(t){t.setMaxZoom(e.maxZoom)}))},u.prototype.setStyles=function(e){this.getClustererInstance().then((function(t){t.setStyles(e.styles)}))},u.prototype.setZoomOnClick=function(e){this.getClustererInstance().then((function(t){void 0!==e.zoomOnClick&&(t.zoomOnClick_=e.zoomOnClick)}))},u.prototype.setAverageCenter=function(e){this.getClustererInstance().then((function(t){void 0!==e.averageCenter&&(t.averageCenter_=e.averageCenter)}))},u.prototype.setImagePath=function(e){this.getClustererInstance().then((function(t){void 0!==e.imagePath&&(t.imagePath_=e.imagePath)}))},u.prototype.setMinimumClusterSize=function(e){this.getClustererInstance().then((function(t){void 0!==e.minimumClusterSize&&(t.minimumClusterSize_=e.minimumClusterSize)}))},u.prototype.setImageExtension=function(e){this.getClustererInstance().then((function(t){void 0!==e.imageExtension&&(t.imageExtension_=e.imageExtension)}))},u.prototype.createClusterEventObservable=function(e){var t=this;return n.Observable.create((function(r){t._zone.runOutsideAngular((function(){t._clustererInstance.then((function(n){n.addListener(e,(function(e){return t._zone.run((function(){return r.next(e)}))}))}))}))}))},u.prototype.setCalculator=function(e){this.getClustererInstance().then((function(t){"function"==typeof e.calculator&&t.setCalculator(e.calculator)}))},u.ctorParameters=function(){return[{type:r.GoogleMapsAPIWrapper},{type:t.NgZone}]},u=o([t.Injectable(),s("design:paramtypes",[r.GoogleMapsAPIWrapper,t.NgZone])],u)}(r.MarkerManager),c=function(){function e(e){this._clusterManager=e,this.clusterClick=new t.EventEmitter,this._observableSubscriptions=[]}return e.prototype.ngOnDestroy=function(){this._clusterManager.clearMarkers(),this._observableSubscriptions.forEach((function(e){return e.unsubscribe()}))},e.prototype.ngOnChanges=function(e){e.gridSize&&this._clusterManager.setGridSize(this),e.maxZoom&&this._clusterManager.setMaxZoom(this),e.zoomOnClick&&this._clusterManager.setZoomOnClick(this),e.averageCenter&&this._clusterManager.setAverageCenter(this),e.minimumClusterSize&&this._clusterManager.setMinimumClusterSize(this),e.imagePath&&this._clusterManager.setImagePath(this),e.imageExtension&&this._clusterManager.setImageExtension(this),e.calculator&&this._clusterManager.setCalculator(this),e.styles&&this._clusterManager.setStyles(this)},e.prototype._addEventListeners=function(){var e=this;[{name:"clusterclick",handler:function(){return e.clusterClick.emit()}}].forEach((function(t){var r=e._clusterManager.createClusterEventObservable(t.name).subscribe(t.handler);e._observableSubscriptions.push(r)}))},e.prototype.ngOnInit=function(){this._addEventListeners(),this._clusterManager.init({gridSize:this.gridSize,maxZoom:this.maxZoom,zoomOnClick:this.zoomOnClick,averageCenter:this.averageCenter,minimumClusterSize:this.minimumClusterSize,styles:this.styles,imagePath:this.imagePath,imageExtension:this.imageExtension,calculator:this.calculator})},e.ctorParameters=function(){return[{type:u}]},o([t.Input(),s("design:type",Number)],e.prototype,"gridSize",void 0),o([t.Input(),s("design:type",Number)],e.prototype,"maxZoom",void 0),o([t.Input(),s("design:type",Boolean)],e.prototype,"zoomOnClick",void 0),o([t.Input(),s("design:type",Boolean)],e.prototype,"averageCenter",void 0),o([t.Input(),s("design:type",Number)],e.prototype,"minimumClusterSize",void 0),o([t.Input(),s("design:type",Array)],e.prototype,"styles",void 0),o([t.Input(),s("design:type",Function)],e.prototype,"calculator",void 0),o([t.Input(),s("design:type",String)],e.prototype,"imagePath",void 0),o([t.Input(),s("design:type",String)],e.prototype,"imageExtension",void 0),o([t.Output(),s("design:type",t.EventEmitter)],e.prototype,"clusterClick",void 0),e=o([t.Directive({selector:"agm-marker-cluster",providers:[u,{provide:r.MarkerManager,useExisting:u},r.InfoWindowManager]}),s("design:paramtypes",[u])],e)}(),l=function(){function e(){}return e=o([t.NgModule({imports:[r.AgmCoreModule],declarations:[c],exports:[c]})],e)}();e.AgmJsMarkerClustererModule=l,e.AgmMarkerCluster=c,e.ClusterManager=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=agm-js-marker-clusterer.umd.min.js.map