UNPKG

@agm/markerclusterer

Version:

Angular Google Maps (AGM) extension for markerclusterer support

17 lines (15 loc) 10.4 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@agm/core"),require("@angular/core"),require("@google/markerclustererplus"),require("rxjs")):"function"==typeof define&&define.amd?define("@agm/markerclusterer",["exports","@agm/core","@angular/core","@google/markerclustererplus","rxjs"],t):t(((e=e||self).agm=e.agm||{},e.agm.markerclusterer={}),e.core,e.ng.core,e.MarkerClusterer,e.rxjs)}(this,(function(e,t,n,r,i){"use strict";r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}u((r=r.apply(e,t||[])).next())}))}function a(e,t){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}Object.create;function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}Object.create;var c=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r._mapsWrapper=t,r._zone=n,r._clustererInstance=new Promise((function(e){r._resolver=e})),r}return function(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.init=function(e){var t=this;this._mapsWrapper.getNativeMap().then((function(n){var i=new r(n,[],e);t._resolver(i)}))},t.prototype.getClustererInstance=function(){return this._clustererInstance},t.prototype.addMarker=function(e){var t=this.getClustererInstance(),n=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,n]).then((function(e){var t=u(e,2),n=t[0],r=t[1];return n.addMarker(r)})),this._markers.set(e,n)},t.prototype.deleteMarker=function(e){var t=this,n=this._markers.get(e);return null==n?Promise.resolve():n.then((function(n){t._zone.run((function(){n.setMap(null),t.getClustererInstance().then((function(r){r.removeMarker(n),t._markers.delete(e)}))}))}))},t.prototype.clearMarkers=function(){return this.getClustererInstance().then((function(e){e.clearMarkers()}))},t.prototype.setGridSize=function(e){this.getClustererInstance().then((function(t){t.setGridSize(e.gridSize)}))},t.prototype.setMaxZoom=function(e){this.getClustererInstance().then((function(t){t.setMaxZoom(e.maxZoom)}))},t.prototype.setStyles=function(e){this.getClustererInstance().then((function(t){t.setStyles(e.styles)}))},t.prototype.setZoomOnClick=function(e){this.getClustererInstance().then((function(t){void 0!==e.zoomOnClick&&t.setZoomOnClick(e.zoomOnClick)}))},t.prototype.setAverageCenter=function(e){this.getClustererInstance().then((function(t){void 0!==e.averageCenter&&t.setAverageCenter(e.averageCenter)}))},t.prototype.setImagePath=function(e){this.getClustererInstance().then((function(t){void 0!==e.imagePath&&t.setImagePath(e.imagePath)}))},t.prototype.setMinimumClusterSize=function(e){this.getClustererInstance().then((function(t){void 0!==e.minimumClusterSize&&t.setMinimumClusterSize(e.minimumClusterSize)}))},t.prototype.setImageExtension=function(e){this.getClustererInstance().then((function(t){void 0!==e.imageExtension&&t.setImageExtension(e.imageExtension)}))},t.prototype.createClusterEventObservable=function(e){var t=this;return new i.Observable((function(n){t._zone.runOutsideAngular((function(){t._clustererInstance.then((function(r){r.addListener(e,(function(e){return t._zone.run((function(){return n.next(e)}))}))}))}))}))},t.prototype.setCalculator=function(e){this.getClustererInstance().then((function(t){"function"==typeof e.calculator&&t.setCalculator(e.calculator)}))},t.prototype.setClusterClass=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return void 0===e.clusterClass?[3,2]:[4,this.getClustererInstance()];case 1:t.sent().setClusterClass(e.clusterClass),t.label=2;case 2:return[2]}}))}))},t.prototype.setEnableRetinaIcons=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return void 0===e.enableRetinaIcons?[3,2]:[4,this.getClustererInstance()];case 1:t.sent().setEnableRetinaIcons(e.enableRetinaIcons),t.label=2;case 2:return[2]}}))}))},t.prototype.setIgnoreHidden=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return void 0===e.ignoreHidden?[3,2]:[4,this.getClustererInstance()];case 1:t.sent().setIgnoreHidden(e.ignoreHidden),t.label=2;case 2:return[2]}}))}))},t.prototype.setImageSizes=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return void 0===e.imageSizes?[3,2]:[4,this.getClustererInstance()];case 1:t.sent().setImageSizes(e.imageSizes),t.label=2;case 2:return[2]}}))}))},t.prototype.setTitle=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return void 0===e.title?[3,2]:[4,this.getClustererInstance()];case 1:t.sent().setTitle(e.title),t.label=2;case 2:return[2]}}))}))},t}(t.MarkerManager);c.decorators=[{type:n.Injectable}],c.ctorParameters=function(){return[{type:t.GoogleMapsAPIWrapper},{type:n.NgZone}]};var l=function(){function e(e){this._clusterManager=e,this.clusterClick=new n.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.clusterClass&&this._clusterManager.setClusterClass(this),e.enableRetinaIcons&&this._clusterManager.setEnableRetinaIcons(this),e.ignoreHidden&&this._clusterManager.setIgnoreHidden(this),e.imageSizes&&this._clusterManager.setImageSizes(this),e.title&&this._clusterManager.setTitle(this)},e.prototype._addEventListeners=function(){var e=this;[{name:"clusterclick",handler:function(){return e.clusterClick.emit()}}].forEach((function(t){var n=e._clusterManager.createClusterEventObservable(t.name).subscribe(t.handler);e._observableSubscriptions.push(n)}))},e.prototype.ngOnInit=function(){this._addEventListeners(),this._clusterManager.init({averageCenter:this.averageCenter,calculator:this.calculator,clusterClass:this.clusterClass,enableRetinaIcons:this.enableRetinaIcons,gridSize:this.gridSize,ignoreHidden:this.ignoreHidden,imageExtension:this.imageExtension,imagePath:this.imagePath,imageSizes:this.imageSizes,maxZoom:this.maxZoom,minimumClusterSize:this.minimumClusterSize,styles:this.styles,title:this.title,zoomOnClick:this.zoomOnClick})},e}();l.decorators=[{type:n.Directive,args:[{selector:"agm-marker-cluster",providers:[c,{provide:t.MarkerManager,useExisting:c},t.InfoWindowManager]}]}],l.ctorParameters=function(){return[{type:c}]},l.propDecorators={gridSize:[{type:n.Input}],maxZoom:[{type:n.Input}],zoomOnClick:[{type:n.Input}],averageCenter:[{type:n.Input}],minimumClusterSize:[{type:n.Input}],styles:[{type:n.Input}],calculator:[{type:n.Input}],imagePath:[{type:n.Input}],imageExtension:[{type:n.Input}],clusterClass:[{type:n.Input}],enableRetinaIcons:[{type:n.Input}],ignoreHidden:[{type:n.Input}],imageSizes:[{type:n.Input}],title:[{type:n.Input}],clusterClick:[{type:n.Output}]};var p=function(){};p.decorators=[{type:n.NgModule,args:[{imports:[t.AgmCoreModule],declarations:[l],exports:[l]}]}],e.AgmMarkerCluster=l,e.AgmMarkerClustererModule=p,e.ClusterManager=c,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=agm-markerclusterer.umd.min.js.map