UNPKG

google-clustr

Version:

Performant Google Maps Point Clustering

17 lines (16 loc) 41.1 kB
var ct=Object.create;var W=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var O=(e,r)=>()=>(e&&(r=e(e=0)),r);var j=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),gt=(e,r)=>{for(var t in r)W(e,t,{get:r[t],enumerable:!0})},ve=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ut(r))!pt.call(e,o)&&o!==t&&W(e,o,{get:()=>r[o],enumerable:!(n=ft(r,o))||n.enumerable});return e};var U=(e,r,t)=>(t=e!=null?ct(ht(e)):{},ve(r||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e)),dt=e=>ve(W({},"__esModule",{value:!0}),e);var Ce=j((pr,xe)=>{var vt="Expected a function",Le=NaN,yt="[object Symbol]",bt=/^\s+|\s+$/g,Lt=/^[-+]0x[0-9a-f]+$/i,kt=/^0b[01]+$/i,xt=/^0o[0-7]+$/i,Ct=parseInt,wt=typeof global=="object"&&global&&global.Object===Object&&global,Dt=typeof self=="object"&&self&&self.Object===Object&&self,It=wt||Dt||Function("return this")(),_t=Object.prototype,Pt=_t.toString,Mt=Math.max,Ot=Math.min,ne=function(){return It.Date.now()};function St(e,r,t){var n,o,a,s,g,d,c=0,u=!1,f=!1,h=!0;if(typeof e!="function")throw new TypeError(vt);r=ke(r)||0,oe(t)&&(u=!!t.leading,f="maxWait"in t,a=f?Mt(ke(t.maxWait)||0,r):a,h="trailing"in t?!!t.trailing:h);function l(k){var w=n,A=o;return n=o=void 0,c=k,s=e.apply(A,w),s}function i(k){return c=k,g=setTimeout(v,r),u?l(k):s}function p(k){var w=k-d,A=k-c,z=r-w;return f?Ot(z,a-A):z}function m(k){var w=k-d,A=k-c;return d===void 0||w>=r||w<0||f&&A>=a}function v(){var k=ne();if(m(k))return y(k);g=setTimeout(v,p(k))}function y(k){return g=void 0,h&&n?l(k):(n=o=void 0,s)}function b(){g!==void 0&&clearTimeout(g),c=0,n=d=o=g=void 0}function L(){return g===void 0?s:y(ne())}function x(){var k=ne(),w=m(k);if(n=arguments,o=this,d=k,w){if(g===void 0)return i(d);if(f)return g=setTimeout(v,r),l(d)}return g===void 0&&(g=setTimeout(v,r)),s}return x.cancel=b,x.flush=L,x}function oe(e){var r=typeof e;return!!e&&(r=="object"||r=="function")}function Tt(e){return!!e&&typeof e=="object"}function Et(e){return typeof e=="symbol"||Tt(e)&&Pt.call(e)==yt}function ke(e){if(typeof e=="number")return e;if(Et(e))return Le;if(oe(e)){var r=typeof e.valueOf=="function"?e.valueOf():e;e=oe(r)?r+"":r}if(typeof e!="string")return e===0?e:+e;e=e.replace(bt,"");var t=kt.test(e);return t||xt.test(e)?Ct(e.slice(2),t?2:8):Lt.test(e)?Le:+e}xe.exports=St});function B(){if(!G&&(G=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!G))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return G(At)}var G,At,se=O(()=>{At=new Uint8Array(16)});var we,De=O(()=>{we=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i});function jt(e){return typeof e=="string"&&we.test(e)}var S,F=O(()=>{De();S=jt});function Rt(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(D[e[r+0]]+D[e[r+1]]+D[e[r+2]]+D[e[r+3]]+"-"+D[e[r+4]]+D[e[r+5]]+"-"+D[e[r+6]]+D[e[r+7]]+"-"+D[e[r+8]]+D[e[r+9]]+"-"+D[e[r+10]]+D[e[r+11]]+D[e[r+12]]+D[e[r+13]]+D[e[r+14]]+D[e[r+15]]).toLowerCase();if(!S(t))throw TypeError("Stringified UUID is invalid");return t}var D,$,T,N=O(()=>{F();D=[];for($=0;$<256;++$)D.push(($+256).toString(16).substr(1));T=Rt});function Ht(e,r,t){var n=r&&t||0,o=r||new Array(16);e=e||{};var a=e.node||Ie,s=e.clockseq!==void 0?e.clockseq:ie;if(a==null||s==null){var g=e.random||(e.rng||B)();a==null&&(a=Ie=[g[0]|1,g[1],g[2],g[3],g[4],g[5]]),s==null&&(s=ie=(g[6]<<8|g[7])&16383)}var d=e.msecs!==void 0?e.msecs:Date.now(),c=e.nsecs!==void 0?e.nsecs:le+1,u=d-ae+(c-le)/1e4;if(u<0&&e.clockseq===void 0&&(s=s+1&16383),(u<0||d>ae)&&e.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ae=d,le=c,ie=s,d+=122192928e5;var f=((d&268435455)*1e4+c)%4294967296;o[n++]=f>>>24&255,o[n++]=f>>>16&255,o[n++]=f>>>8&255,o[n++]=f&255;var h=d/4294967296*1e4&268435455;o[n++]=h>>>8&255,o[n++]=h&255,o[n++]=h>>>24&15|16,o[n++]=h>>>16&255,o[n++]=s>>>8|128,o[n++]=s&255;for(var l=0;l<6;++l)o[n+l]=a[l];return r||T(o)}var Ie,ie,ae,le,_e,Pe=O(()=>{se();N();ae=0,le=0;_e=Ht});function Ut(e){if(!S(e))throw TypeError("Invalid UUID");var r,t=new Uint8Array(16);return t[0]=(r=parseInt(e.slice(0,8),16))>>>24,t[1]=r>>>16&255,t[2]=r>>>8&255,t[3]=r&255,t[4]=(r=parseInt(e.slice(9,13),16))>>>8,t[5]=r&255,t[6]=(r=parseInt(e.slice(14,18),16))>>>8,t[7]=r&255,t[8]=(r=parseInt(e.slice(19,23),16))>>>8,t[9]=r&255,t[10]=(r=parseInt(e.slice(24,36),16))/1099511627776&255,t[11]=r/4294967296&255,t[12]=r>>>24&255,t[13]=r>>>16&255,t[14]=r>>>8&255,t[15]=r&255,t}var X,ce=O(()=>{F();X=Ut});function Bt(e){e=unescape(encodeURIComponent(e));for(var r=[],t=0;t<e.length;++t)r.push(e.charCodeAt(t));return r}function Y(e,r,t){function n(o,a,s,g){if(typeof o=="string"&&(o=Bt(o)),typeof a=="string"&&(a=X(a)),a.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+o.length);if(d.set(a),d.set(o,a.length),d=t(d),d[6]=d[6]&15|r,d[8]=d[8]&63|128,s){g=g||0;for(var c=0;c<16;++c)s[g+c]=d[c];return s}return T(d)}try{n.name=e}catch{}return n.DNS=Ft,n.URL=Nt,n}var Ft,Nt,fe=O(()=>{N();ce();Ft="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Nt="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function Zt(e){if(typeof e=="string"){var r=unescape(encodeURIComponent(e));e=new Uint8Array(r.length);for(var t=0;t<r.length;++t)e[t]=r.charCodeAt(t)}return Vt(zt(Wt(e),e.length*8))}function Vt(e){for(var r=[],t=e.length*32,n="0123456789abcdef",o=0;o<t;o+=8){var a=e[o>>5]>>>o%32&255,s=parseInt(n.charAt(a>>>4&15)+n.charAt(a&15),16);r.push(s)}return r}function Me(e){return(e+64>>>9<<4)+14+1}function zt(e,r){e[r>>5]|=128<<r%32,e[Me(r)-1]=r;for(var t=1732584193,n=-271733879,o=-1732584194,a=271733878,s=0;s<e.length;s+=16){var g=t,d=n,c=o,u=a;t=I(t,n,o,a,e[s],7,-680876936),a=I(a,t,n,o,e[s+1],12,-389564586),o=I(o,a,t,n,e[s+2],17,606105819),n=I(n,o,a,t,e[s+3],22,-1044525330),t=I(t,n,o,a,e[s+4],7,-176418897),a=I(a,t,n,o,e[s+5],12,1200080426),o=I(o,a,t,n,e[s+6],17,-1473231341),n=I(n,o,a,t,e[s+7],22,-45705983),t=I(t,n,o,a,e[s+8],7,1770035416),a=I(a,t,n,o,e[s+9],12,-1958414417),o=I(o,a,t,n,e[s+10],17,-42063),n=I(n,o,a,t,e[s+11],22,-1990404162),t=I(t,n,o,a,e[s+12],7,1804603682),a=I(a,t,n,o,e[s+13],12,-40341101),o=I(o,a,t,n,e[s+14],17,-1502002290),n=I(n,o,a,t,e[s+15],22,1236535329),t=_(t,n,o,a,e[s+1],5,-165796510),a=_(a,t,n,o,e[s+6],9,-1069501632),o=_(o,a,t,n,e[s+11],14,643717713),n=_(n,o,a,t,e[s],20,-373897302),t=_(t,n,o,a,e[s+5],5,-701558691),a=_(a,t,n,o,e[s+10],9,38016083),o=_(o,a,t,n,e[s+15],14,-660478335),n=_(n,o,a,t,e[s+4],20,-405537848),t=_(t,n,o,a,e[s+9],5,568446438),a=_(a,t,n,o,e[s+14],9,-1019803690),o=_(o,a,t,n,e[s+3],14,-187363961),n=_(n,o,a,t,e[s+8],20,1163531501),t=_(t,n,o,a,e[s+13],5,-1444681467),a=_(a,t,n,o,e[s+2],9,-51403784),o=_(o,a,t,n,e[s+7],14,1735328473),n=_(n,o,a,t,e[s+12],20,-1926607734),t=P(t,n,o,a,e[s+5],4,-378558),a=P(a,t,n,o,e[s+8],11,-2022574463),o=P(o,a,t,n,e[s+11],16,1839030562),n=P(n,o,a,t,e[s+14],23,-35309556),t=P(t,n,o,a,e[s+1],4,-1530992060),a=P(a,t,n,o,e[s+4],11,1272893353),o=P(o,a,t,n,e[s+7],16,-155497632),n=P(n,o,a,t,e[s+10],23,-1094730640),t=P(t,n,o,a,e[s+13],4,681279174),a=P(a,t,n,o,e[s],11,-358537222),o=P(o,a,t,n,e[s+3],16,-722521979),n=P(n,o,a,t,e[s+6],23,76029189),t=P(t,n,o,a,e[s+9],4,-640364487),a=P(a,t,n,o,e[s+12],11,-421815835),o=P(o,a,t,n,e[s+15],16,530742520),n=P(n,o,a,t,e[s+2],23,-995338651),t=M(t,n,o,a,e[s],6,-198630844),a=M(a,t,n,o,e[s+7],10,1126891415),o=M(o,a,t,n,e[s+14],15,-1416354905),n=M(n,o,a,t,e[s+5],21,-57434055),t=M(t,n,o,a,e[s+12],6,1700485571),a=M(a,t,n,o,e[s+3],10,-1894986606),o=M(o,a,t,n,e[s+10],15,-1051523),n=M(n,o,a,t,e[s+1],21,-2054922799),t=M(t,n,o,a,e[s+8],6,1873313359),a=M(a,t,n,o,e[s+15],10,-30611744),o=M(o,a,t,n,e[s+6],15,-1560198380),n=M(n,o,a,t,e[s+13],21,1309151649),t=M(t,n,o,a,e[s+4],6,-145523070),a=M(a,t,n,o,e[s+11],10,-1120210379),o=M(o,a,t,n,e[s+2],15,718787259),n=M(n,o,a,t,e[s+9],21,-343485551),t=E(t,g),n=E(n,d),o=E(o,c),a=E(a,u)}return[t,n,o,a]}function Wt(e){if(e.length===0)return[];for(var r=e.length*8,t=new Uint32Array(Me(r)),n=0;n<r;n+=8)t[n>>5]|=(e[n/8]&255)<<n%32;return t}function E(e,r){var t=(e&65535)+(r&65535),n=(e>>16)+(r>>16)+(t>>16);return n<<16|t&65535}function qt(e,r){return e<<r|e>>>32-r}function K(e,r,t,n,o,a){return E(qt(E(E(r,e),E(n,a)),o),t)}function I(e,r,t,n,o,a,s){return K(r&t|~r&n,e,r,o,a,s)}function _(e,r,t,n,o,a,s){return K(r&n|t&~n,e,r,o,a,s)}function P(e,r,t,n,o,a,s){return K(r^t^n,e,r,o,a,s)}function M(e,r,t,n,o,a,s){return K(t^(r|~n),e,r,o,a,s)}var Oe,Se=O(()=>{Oe=Zt});var Gt,Te,Ee=O(()=>{fe();Se();Gt=Y("v3",48,Oe),Te=Gt});function $t(e,r,t){e=e||{};var n=e.random||(e.rng||B)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,r){t=t||0;for(var o=0;o<16;++o)r[t+o]=n[o];return r}return T(n)}var Ae,je=O(()=>{se();N();Ae=$t});function Xt(e,r,t,n){switch(e){case 0:return r&t^~r&n;case 1:return r^t^n;case 2:return r&t^r&n^t&n;case 3:return r^t^n}}function ue(e,r){return e<<r|e>>>32-r}function Yt(e){var r=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var n=unescape(encodeURIComponent(e));e=[];for(var o=0;o<n.length;++o)e.push(n.charCodeAt(o))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,s=Math.ceil(a/16),g=new Array(s),d=0;d<s;++d){for(var c=new Uint32Array(16),u=0;u<16;++u)c[u]=e[d*64+u*4]<<24|e[d*64+u*4+1]<<16|e[d*64+u*4+2]<<8|e[d*64+u*4+3];g[d]=c}g[s-1][14]=(e.length-1)*8/Math.pow(2,32),g[s-1][14]=Math.floor(g[s-1][14]),g[s-1][15]=(e.length-1)*8&4294967295;for(var f=0;f<s;++f){for(var h=new Uint32Array(80),l=0;l<16;++l)h[l]=g[f][l];for(var i=16;i<80;++i)h[i]=ue(h[i-3]^h[i-8]^h[i-14]^h[i-16],1);for(var p=t[0],m=t[1],v=t[2],y=t[3],b=t[4],L=0;L<80;++L){var x=Math.floor(L/20),k=ue(p,5)+Xt(x,m,v,y)+b+r[x]+h[L]>>>0;b=y,y=v,v=ue(m,30)>>>0,m=p,p=k}t[0]=t[0]+p>>>0,t[1]=t[1]+m>>>0,t[2]=t[2]+v>>>0,t[3]=t[3]+y>>>0,t[4]=t[4]+b>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var Re,He=O(()=>{Re=Yt});var Kt,Ue,Be=O(()=>{fe();He();Kt=Y("v5",80,Re),Ue=Kt});var Fe,Ne=O(()=>{Fe="00000000-0000-0000-0000-000000000000"});function Qt(e){if(!S(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}var Ze,Ve=O(()=>{F();Ze=Qt});var ze={};gt(ze,{NIL:()=>Fe,parse:()=>X,stringify:()=>T,v1:()=>_e,v3:()=>Te,v4:()=>Ae,v5:()=>Ue,validate:()=>S,version:()=>Ze});var We=O(()=>{Pe();Ee();je();Be();Ne();Ve();F();N();ce()});var Ge=j((Kr,qe)=>{"use strict";function he(e,r){if(!e||!r||!e.length||!r.length)throw new Error("Bad alphabet");this.srcAlphabet=e,this.dstAlphabet=r}he.prototype.convert=function(e){var r,t,n,o={},a=this.srcAlphabet.length,s=this.dstAlphabet.length,g=e.length,d=typeof e=="string"?"":[];if(!this.isValid(e))throw new Error('Number "'+e+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return e;for(r=0;r<g;r++)o[r]=this.srcAlphabet.indexOf(e[r]);do{for(t=0,n=0,r=0;r<g;r++)t=t*a+o[r],t>=s?(o[n++]=parseInt(t/s,10),t=t%s):n>0&&(o[n++]=0);g=n,d=this.dstAlphabet.slice(t,t+1).concat(d)}while(n!==0);return d};he.prototype.isValid=function(e){for(var r=0;r<e.length;++r)if(this.srcAlphabet.indexOf(e[r])===-1)return!1;return!0};qe.exports=he});var Xe=j((Qr,$e)=>{var Jt=Ge();function Z(e,r){var t=new Jt(e,r);return function(n){return t.convert(n)}}Z.BIN="01";Z.OCT="01234567";Z.DEC="0123456789";Z.HEX="0123456789abcdef";$e.exports=Z});var Qe=j((Jr,Ke)=>{var{v4:pe}=(We(),dt(ze)),Q=Xe(),ge="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",er="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~",tr={consistentLength:!0},de,Ye=(e,r,t)=>{let n=r(e.toLowerCase().replace(/-/g,""));return!t||!t.consistentLength?n:n.padStart(t.shortIdLength,t.paddingChar)},rr=(e,r)=>{let n=r(e).padStart(32,"0").match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/);return[n[1],n[2],n[3],n[4],n[5]].join("-")},nr=e=>Math.ceil(Math.log(2**128)/Math.log(e));Ke.exports=(()=>{let e=(r,t)=>{let n=r||ge,o={...tr,...t};if([...new Set(Array.from(n))].length!==n.length)throw new Error("The provided Alphabet has duplicate characters resulting in unreliable results");let a=nr(n.length),s={shortIdLength:a,consistentLength:o.consistentLength,paddingChar:n[0]},g=Q(Q.HEX,n),d=Q(n,Q.HEX),c=()=>Ye(pe(),g,s),u={new:c,generate:c,uuid:pe,fromUUID:f=>Ye(f,g,s),toUUID:f=>rr(f,d),alphabet:n,maxLength:a};return Object.freeze(u),u};return e.constants={flickrBase58:ge,cookieBase90:er},e.uuid=pe,e.generate=()=>(de||(de=e(ge).generate),de()),e})()});var tt=j((en,et)=>{"use strict";function Je(e,r){function t(){}t.prototype=r.prototype,e.superClass_=r.prototype,e.prototype=new t,e.prototype.constructor=e}function C(e,r,t,n){this.marker_=r,this.handCursorURL_=r.handCursorURL,this.labelDiv_=document.createElement("div"),typeof e<"u"&&(this.labelDiv_.id=e),this.labelDiv_.style.cssText="position: absolute; overflow: hidden;",this.crossDiv_=C.getSharedCross(t)}Je(C,google.maps.OverlayView);C.getSharedCross=function(e){var r;return typeof C.getSharedCross.crossDiv>"u"&&(r=document.createElement("img"),r.style.cssText="position: absolute; z-index: 1000002; display: none;",r.style.marginLeft="-8px",r.style.marginTop="-9px",r.src=e,C.getSharedCross.crossDiv=r),C.getSharedCross.crossDiv};C.prototype.onAdd=function(){var e=this,r=!1,t=!1,n,o,a,s,g,d,c,u=20,f="url("+this.handCursorURL_+")",h=function(i){i.preventDefault&&i.preventDefault(),i.cancelBubble=!0,i.stopPropagation&&i.stopPropagation()},l=function(){e.marker_.setAnimation(null)};this.getPanes().overlayMouseTarget.appendChild(this.labelDiv_),typeof C.getSharedCross.processed>"u"&&(this.getPanes().overlayMouseTarget.appendChild(this.crossDiv_),C.getSharedCross.processed=!0),this.listeners_=[google.maps.event.addDomListener(this.labelDiv_,"mouseover",function(i){(e.marker_.getDraggable()||e.marker_.getClickable())&&(this.style.cursor="pointer",google.maps.event.trigger(e.marker_,"mouseover",i))}),google.maps.event.addDomListener(this.labelDiv_,"mouseout",function(i){(e.marker_.getDraggable()||e.marker_.getClickable())&&!t&&(this.style.cursor=e.marker_.getCursor(),google.maps.event.trigger(e.marker_,"mouseout",i))}),google.maps.event.addDomListener(this.labelDiv_,"mousedown",function(i){t=!1,e.marker_.getDraggable()&&(r=!0,this.style.cursor=f),(e.marker_.getDraggable()||e.marker_.getClickable())&&(google.maps.event.trigger(e.marker_,"mousedown",i),h(i))}),google.maps.event.addDomListener(document,"mouseup",function(i){var p;if(r&&(r=!1,e.eventDiv_.style.cursor="pointer",google.maps.event.trigger(e.marker_,"mouseup",i)),t){if(g){p=e.getProjection().fromLatLngToDivPixel(e.marker_.getPosition()),p.y+=u,e.marker_.setPosition(e.getProjection().fromDivPixelToLatLng(p));try{e.marker_.setAnimation(google.maps.Animation.BOUNCE),setTimeout(l,1406)}catch{}}e.crossDiv_.style.display="none",e.marker_.setZIndex(n),s=!0,t=!1,i.latLng=e.marker_.getPosition(),google.maps.event.trigger(e.marker_,"dragend",i)}}),google.maps.event.addListener(e.marker_.getMap(),"mousemove",function(i){var p;r&&(t?(i.latLng=new google.maps.LatLng(i.latLng.lat()-o,i.latLng.lng()-a),p=e.getProjection().fromLatLngToDivPixel(i.latLng),g&&(e.crossDiv_.style.left=p.x+"px",e.crossDiv_.style.top=p.y+"px",e.crossDiv_.style.display="",p.y-=u),e.marker_.setPosition(e.getProjection().fromDivPixelToLatLng(p)),g&&(e.eventDiv_.style.top=p.y+u+"px"),google.maps.event.trigger(e.marker_,"drag",i)):(o=i.latLng.lat()-e.marker_.getPosition().lat(),a=i.latLng.lng()-e.marker_.getPosition().lng(),n=e.marker_.getZIndex(),d=e.marker_.getPosition(),c=e.marker_.getMap().getCenter(),g=e.marker_.get("raiseOnDrag"),t=!0,e.marker_.setZIndex(1e6),i.latLng=e.marker_.getPosition(),google.maps.event.trigger(e.marker_,"dragstart",i)))}),google.maps.event.addDomListener(document,"keydown",function(i){t&&i.keyCode===27&&(g=!1,e.marker_.setPosition(d),e.marker_.getMap().setCenter(c),google.maps.event.trigger(document,"mouseup",i))}),google.maps.event.addDomListener(this.labelDiv_,"click",function(i){(e.marker_.getDraggable()||e.marker_.getClickable())&&(s?s=!1:(google.maps.event.trigger(e.marker_,"click",i),h(i)))}),google.maps.event.addDomListener(this.labelDiv_,"dblclick",function(i){(e.marker_.getDraggable()||e.marker_.getClickable())&&(google.maps.event.trigger(e.marker_,"dblclick",i),h(i))}),google.maps.event.addListener(this.marker_,"dragstart",function(i){t||(g=this.get("raiseOnDrag"))}),google.maps.event.addListener(this.marker_,"drag",function(i){t||g&&(e.setPosition(u),e.labelDiv_.style.zIndex=1e6+(this.get("labelInBackground")?-1:1))}),google.maps.event.addListener(this.marker_,"dragend",function(i){t||g&&e.setPosition(0)}),google.maps.event.addListener(this.marker_,"position_changed",function(){e.setPosition()}),google.maps.event.addListener(this.marker_,"zindex_changed",function(){e.setZIndex()}),google.maps.event.addListener(this.marker_,"visible_changed",function(){e.setVisible()}),google.maps.event.addListener(this.marker_,"labelvisible_changed",function(){e.setVisible()}),google.maps.event.addListener(this.marker_,"title_changed",function(){e.setTitle()}),google.maps.event.addListener(this.marker_,"labelcontent_changed",function(){e.setContent()}),google.maps.event.addListener(this.marker_,"labelanchor_changed",function(){e.setAnchor()}),google.maps.event.addListener(this.marker_,"labelclass_changed",function(){e.setStyles()}),google.maps.event.addListener(this.marker_,"labelstyle_changed",function(){e.setStyles()})]};C.prototype.onRemove=function(){var e;for(this.labelDiv_.parentNode.removeChild(this.labelDiv_),e=0;e<this.listeners_.length;e++)google.maps.event.removeListener(this.listeners_[e])};C.prototype.draw=function(){this.setContent(),this.setTitle(),this.setStyles(),this.setDataSet()};C.prototype.setContent=function(){var e=this.marker_.get("labelContent");typeof e.nodeType>"u"?this.labelDiv_.innerHTML=e:(this.labelDiv_.innerHTML="",this.labelDiv_.appendChild(e))};C.prototype.setDataSet=function(){this.marker_.get("data").forEach((r,t)=>{this.labelDiv_.dataset[Object.keys(r)[0]]=r[Object.keys(r)[0]]})};C.prototype.setTitle=function(){this.labelDiv_.title=this.marker_.getTitle()||""};C.prototype.setStyles=function(){var e,r;this.labelDiv_.className=this.marker_.get("labelClass"),this.labelDiv_.style.cssText="",r=this.marker_.get("labelStyle");for(e in r)r.hasOwnProperty(e)&&(this.labelDiv_.style[e]=r[e]);this.setMandatoryStyles()};C.prototype.setMandatoryStyles=function(){this.labelDiv_.style.position="absolute",this.labelDiv_.style.overflow="hidden",typeof this.labelDiv_.style.opacity<"u"&&this.labelDiv_.style.opacity!==""&&(this.labelDiv_.style.MsFilter='"progid:DXImageTransform.Microsoft.Alpha(opacity='+this.labelDiv_.style.opacity*100+')"',this.labelDiv_.style.filter="alpha(opacity="+this.labelDiv_.style.opacity*100+")"),this.setAnchor(),this.setPosition(),this.setVisible()};C.prototype.setAnchor=function(){var e=this.marker_.get("labelAnchor");this.labelDiv_.style.marginLeft=-e.x+"px",this.labelDiv_.style.marginTop=-e.y+"px"};C.prototype.setPosition=function(e){var r=this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());typeof e>"u"&&(e=0),this.labelDiv_.style.left=Math.round(r.x)+"px",this.labelDiv_.style.top=Math.round(r.y-e)+"px",this.setZIndex()};C.prototype.setZIndex=function(){var e=this.marker_.get("labelInBackground")?-1:1;typeof this.marker_.getZIndex()>"u"?this.labelDiv_.style.zIndex=parseInt(this.labelDiv_.style.top,10)+e:this.labelDiv_.style.zIndex=this.marker_.getZIndex()+e};C.prototype.setVisible=function(){this.marker_.get("labelVisible")?this.labelDiv_.style.display=this.marker_.getVisible()?"block":"none":this.labelDiv_.style.display="none"};function me(e){e=e||{},e.labelContent=e.labelContent||"",e.labelAnchor=e.labelAnchor||new google.maps.Point(0,0),e.labelClass=e.labelClass||"markerLabels",e.labelStyle=e.labelStyle||{},e.labelInBackground=e.labelInBackground||!1,typeof e.labelVisible>"u"&&(e.labelVisible=!0),typeof e.raiseOnDrag>"u"&&(e.raiseOnDrag=!0),typeof e.clickable>"u"&&(e.clickable=!0),typeof e.draggable>"u"&&(e.draggable=!1),typeof e.optimized>"u"&&(e.optimized=!1),e.crossImage=e.crossImage||"http"+(document.location.protocol==="https:"?"s":"")+"://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png",e.handCursor=e.handCursor||"http"+(document.location.protocol==="https:"?"s":"")+"://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur",e.optimized=!1,this.label=new C(e.id,this,e.crossImage,e.handCursor),google.maps.Marker.apply(this,arguments)}Je(me,google.maps.Marker);me.prototype.setMap=function(e){google.maps.Marker.prototype.setMap.apply(this,arguments),this.label.setMap(e)};et.exports=me});var nt=j((tn,rt)=>{"use strict";var or={}.hasOwnProperty,sr=[].slice,ir=function(){function e(c,u){var f,h,l,i;this.map=c,u==null&&(u={});for(f in u)or.call(u,f)&&(h=u[f],this[f]=h);for(this.e=new this.constructor.g(this.map),this.n(),this.b={},i=["click","zoom_changed","maptypeid_changed"],h=0,l=i.length;h<l;h++)f=i[h],r.addListener(this.map,f,function(p){return function(){return p.unspiderfy()}}(this))}var r,t,n,o,a,s,g,d;for(s=e.prototype,d=[e,s],o=0,a=d.length;o<a;o++)n=d[o],n.VERSION="0.3.3";return t=google.maps,r=t.event,a=t.MapTypeId,g=2*Math.PI,s.keepSpiderfied=!1,s.markersWontHide=!1,s.markersWontMove=!1,s.nearbyDistance=20,s.circleSpiralSwitchover=9,s.circleFootSeparation=23,s.circleStartAngle=g/12,s.spiralFootSeparation=26,s.spiralLengthStart=11,s.spiralLengthFactor=4,s.spiderfiedZIndex=1e3,s.usualLegZIndex=10,s.highlightedLegZIndex=20,s.event="click",s.minZoomLevel=!1,s.legWeight=1.5,s.legColors={usual:{},highlighted:{}},o=s.legColors.usual,n=s.legColors.highlighted,o[a.HYBRID]=o[a.SATELLITE]="#fff",n[a.HYBRID]=n[a.SATELLITE]="#f00",o[a.TERRAIN]=o[a.ROADMAP]="#444",n[a.TERRAIN]=n[a.ROADMAP]="#f00",s.n=function(){this.a=[],this.j=[]},s.addMarker=function(c){var u;return c._oms!=null?this:(c._oms=!0,u=[r.addListener(c,this.event,function(f){return function(h){return f.G(c,h)}}(this))],this.markersWontHide||u.push(r.addListener(c,"visible_changed",function(f){return function(){return f.o(c,!1)}}(this))),this.markersWontMove||u.push(r.addListener(c,"position_changed",function(f){return function(){return f.o(c,!0)}}(this))),this.j.push(u),this.a.push(c),this)},s.o=function(c,u){if(c._omsData!=null&&(u||!c.getVisible())&&this.s==null&&this.t==null)return this.unspiderfy(u?c:null)},s.getMarkers=function(){return this.a.slice(0)},s.removeMarker=function(c){var u,f,h,l,i;if(c._omsData!=null&&this.unspiderfy(),u=this.m(this.a,c),0>u)return this;for(h=this.j.splice(u,1)[0],l=0,i=h.length;l<i;l++)f=h[l],r.removeListener(f);return delete c._oms,this.a.splice(u,1),this},s.clearMarkers=function(){var c,u,f,h,l,i,p,m;for(this.unspiderfy(),m=this.a,c=h=0,i=m.length;h<i;c=++h){for(f=m[c],u=this.j[c],l=0,p=u.length;l<p;l++)c=u[l],r.removeListener(c);delete f._oms}return this.n(),this},s.addListener=function(c,u){var f;return((f=this.b)[c]!=null?f[c]:f[c]=[]).push(u),this},s.removeListener=function(c,u){var f;return f=this.m(this.b[c],u),0>f||this.b[c].splice(f,1),this},s.clearListeners=function(c){return this.b[c]=[],this},s.trigger=function(){var c,u,f,h,l,i;for(u=arguments[0],c=2<=arguments.length?sr.call(arguments,1):[],u=(f=this.b[u])!=null?f:[],i=[],h=0,l=u.length;h<l;h++)f=u[h],i.push(f.apply(null,c));return i},s.u=function(c,u){var f,h,l,i,p;for(l=this.circleFootSeparation*(2+c)/g,h=g/c,p=[],f=i=0;0<=c?i<c:i>c;f=0<=c?++i:--i)f=this.circleStartAngle+f*h,p.push(new t.Point(u.x+l*Math.cos(f),u.y+l*Math.sin(f)));return p},s.v=function(c,u){var f,h,l,i,p;for(l=this.spiralLengthStart,f=0,p=[],h=i=0;0<=c?i<c:i>c;h=0<=c?++i:--i)f+=this.spiralFootSeparation/l+5e-4*h,h=new t.Point(u.x+l*Math.cos(f),u.y+l*Math.sin(f)),l+=g*this.spiralLengthFactor/f,p.push(h);return p},s.G=function(c,u){var f,h,l,i,p,m,v,y,b,L;if(m=c._omsData!=null,m&&this.keepSpiderfied||(this.event==="mouseover"?(f=this,h=function(){return f.unspiderfy()},window.clearTimeout(s.timeout),s.timeout=setTimeout(h,3e3)):this.unspiderfy()),m||this.map.getStreetView().getVisible()||this.map.getMapTypeId()==="GoogleEarthAPI")return this.trigger("click",c,u);for(h=[],m=[],l=this.nearbyDistance,v=l*l,p=this.c(c.position),L=this.a,y=0,b=L.length;y<b;y++)l=L[y],l.map!=null&&l.getVisible()&&(i=this.c(l.position),this.f(i,p)<v?h.push({B:l,p:i}):m.push(l));return h.length===1?this.trigger("click",c,u):this.H(h,m)},s.markersNearMarker=function(c,u){var f,h,l,i,p,m,v,y,b,L;if(u==null&&(u=!1),this.e.getProjection()==null)throw"Must wait for 'idle' event on map before calling markersNearMarker";for(f=this.nearbyDistance,p=f*f,l=this.c(c.position),i=[],y=this.a,m=0,v=y.length;m<v&&(f=y[m],!(f!==c&&f.map!=null&&f.getVisible()&&(h=this.c((b=(L=f._omsData)!=null?L.l:void 0)!=null?b:f.position),this.f(h,l)<p&&(i.push(f),u))));m++);return i},s.markersNearAnyOtherMarker=function(){var c,u,f,h,l,i,p,m,v,y,b,L;if(this.e.getProjection()==null)throw"Must wait for 'idle' event on map before calling markersNearAnyOtherMarker";for(i=this.nearbyDistance,c=i*i,h=this.a,i=[],b=0,f=h.length;b<f;b++)u=h[b],i.push({q:this.c((p=(v=u._omsData)!=null?v.l:void 0)!=null?p:u.position),d:!1});for(b=this.a,u=p=0,v=b.length;p<v;u=++p)if(f=b[u],f.map!=null&&f.getVisible()&&(h=i[u],!h.d)){for(L=this.a,f=m=0,y=L.length;m<y;f=++m)if(l=L[f],f!==u&&l.map!=null&&l.getVisible()&&(l=i[f],(!(f<u)||l.d)&&this.f(h.q,l.q)<c)){h.d=l.d=!0;break}}for(b=this.a,f=[],c=p=0,v=b.length;p<v;c=++p)u=b[c],i[c].d&&f.push(u);return f},s.A=function(c){return{h:function(u){return function(){return c._omsData.i.setOptions({strokeColor:u.legColors.highlighted[u.map.mapTypeId],zIndex:u.highlightedLegZIndex})}}(this),k:function(u){return function(){return c._omsData.i.setOptions({strokeColor:u.legColors.usual[u.map.mapTypeId],zIndex:u.usualLegZIndex})}}(this)}},s.H=function(c,u){var f,h,l,i,p,m,v,y,b,L;return this.minZoomLevel&&this.map.getZoom()<this.minZoomLevel?!1:(this.s=!0,L=c.length,f=this.D(function(){var x,k,w;for(w=[],x=0,k=c.length;x<k;x++)y=c[x],w.push(y.p);return w}()),i=L>=this.circleSpiralSwitchover?this.v(L,f).reverse():this.u(L,f),f=function(){var x,k,w;for(w=[],x=0,k=i.length;x<k;x++)l=i[x],h=this.F(l),b=this.C(c,function(A){return function(z){return A.f(z.p,l)}}(this)),v=b.B,m=new t.Polyline({map:this.map,path:[v.position,h],strokeColor:this.legColors.usual[this.map.mapTypeId],strokeWeight:this.legWeight,zIndex:this.usualLegZIndex}),v._omsData={l:v.position,i:m},this.legColors.highlighted[this.map.mapTypeId]!==this.legColors.usual[this.map.mapTypeId]&&(p=this.A(v),v._omsData.w={h:r.addListener(v,"mouseover",p.h),k:r.addListener(v,"mouseout",p.k)}),v.setPosition(h),v.setZIndex(Math.round(this.spiderfiedZIndex+l.y)),w.push(v);return w}.call(this),delete this.s,this.r=!0,this.trigger("spiderfy",f,u))},s.unspiderfy=function(c){var u,f,h,l,i,p,m;if(c==null&&(c=null),this.r==null)return this;for(this.t=!0,l=[],h=[],m=this.a,i=0,p=m.length;i<p;i++)f=m[i],f._omsData!=null?(f._omsData.i.setMap(null),f!==c&&f.setPosition(f._omsData.l),f.setZIndex(null),u=f._omsData.w,u!=null&&(r.removeListener(u.h),r.removeListener(u.k)),delete f._omsData,l.push(f)):h.push(f);return delete this.t,delete this.r,this.trigger("unspiderfy",l,h),this},s.f=function(c,u){var f,h;return f=c.x-u.x,h=c.y-u.y,f*f+h*h},s.D=function(c){var u,f,h,l,i;for(l=f=h=0,i=c.length;l<i;l++)u=c[l],f+=u.x,h+=u.y;return c=c.length,new t.Point(f/c,h/c)},s.c=function(c){return this.e.getProjection().fromLatLngToDivPixel(c)},s.F=function(c){return this.e.getProjection().fromDivPixelToLatLng(c)},s.C=function(c,u){var f,h,l,i,p,m;for(l=p=0,m=c.length;p<m;l=++p)i=c[l],i=u(i),(typeof f>"u"||f===null||i<h)&&(h=i,f=l);return c.splice(f,1)[0]},s.m=function(c,u){var f,h,l,i;if(c.indexOf!=null)return c.indexOf(u);for(f=l=0,i=c.length;l<i;f=++l)if(h=c[f],h===u)return f;return-1},e.g=function(c){return this.setMap(c)},e.g.prototype=new t.OverlayView,e.g.prototype.draw=function(){},e}();rt.exports=ir});var at=j((H,V)=>{(function(e,r){"use strict";var t={};e.PubSub?(t=e.PubSub,console.warn("PubSub already loaded, using existing version")):(e.PubSub=t,r(t)),typeof H=="object"?(V!==void 0&&V.exports&&(H=V.exports=t),H.PubSub=t,V.exports=H=t):typeof define=="function"&&define.amd&&define(function(){return t})})(typeof window=="object"&&window||H,function(e){"use strict";var r={},t=-1,n="*";function o(l){var i;for(i in l)if(Object.prototype.hasOwnProperty.call(l,i))return!0;return!1}function a(l){return function(){throw l}}function s(l,i,p){try{l(i,p)}catch(m){setTimeout(a(m),0)}}function g(l,i,p){l(i,p)}function d(l,i,p,m){var v=r[i],y=m?g:s,b;if(!!Object.prototype.hasOwnProperty.call(r,i))for(b in v)Object.prototype.hasOwnProperty.call(v,b)&&y(v[b],l,p)}function c(l,i,p){return function(){var v=String(l),y=v.lastIndexOf(".");for(d(l,l,i,p);y!==-1;)v=v.substr(0,y),y=v.lastIndexOf("."),d(l,v,i,p);d(l,n,i,p)}}function u(l){var i=String(l),p=Boolean(Object.prototype.hasOwnProperty.call(r,i)&&o(r[i]));return p}function f(l){for(var i=String(l),p=u(i)||u(n),m=i.lastIndexOf(".");!p&&m!==-1;)i=i.substr(0,m),m=i.lastIndexOf("."),p=u(i);return p}function h(l,i,p,m){l=typeof l=="symbol"?l.toString():l;var v=c(l,i,m),y=f(l);return y?(p===!0?v():setTimeout(v,0),!0):!1}e.publish=function(l,i){return h(l,i,!1,e.immediateExceptions)},e.publishSync=function(l,i){return h(l,i,!0,e.immediateExceptions)},e.subscribe=function(l,i){if(typeof i!="function")return!1;l=typeof l=="symbol"?l.toString():l,Object.prototype.hasOwnProperty.call(r,l)||(r[l]={});var p="uid_"+String(++t);return r[l][p]=i,p},e.subscribeAll=function(l){return e.subscribe(n,l)},e.subscribeOnce=function(l,i){var p=e.subscribe(l,function(){e.unsubscribe(p),i.apply(this,arguments)});return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(i){var p;for(p in r)Object.prototype.hasOwnProperty.call(r,p)&&p.indexOf(i)===0&&delete r[p]},e.countSubscriptions=function(i){var p,m,v=0;for(p in r)if(Object.prototype.hasOwnProperty.call(r,p)&&p.indexOf(i)===0){for(m in r[p])v++;break}return v},e.getSubscriptions=function(i){var p,m=[];for(p in r)Object.prototype.hasOwnProperty.call(r,p)&&p.indexOf(i)===0&&m.push(p);return m},e.unsubscribe=function(l){var i=function(k){var w;for(w in r)if(Object.prototype.hasOwnProperty.call(r,w)&&w.indexOf(k)===0)return!0;return!1},p=typeof l=="string"&&(Object.prototype.hasOwnProperty.call(r,l)||i(l)),m=!p&&typeof l=="string",v=typeof l=="function",y=!1,b,L,x;if(p){e.clearSubscriptions(l);return}for(b in r)if(Object.prototype.hasOwnProperty.call(r,b)){if(L=r[b],m&&L[l]){delete L[l],y=l;break}if(v)for(x in L)Object.prototype.hasOwnProperty.call(L,x)&&L[x]===l&&(delete L[x],y=!0)}return y}})});var re=class extends google.maps.OverlayView{constructor(r){super(),this.map=r}onRemove(){this.div.parentNode.removeChild(this.div),this.div=null}onAdd(){this.div=document.createElement("div"),this.div.style.position="absolute",this.div.id="GoogleClustrOverlay",this.getPanes().overlayImage.appendChild(this.div)}draw(){let r=this.getProjection(),t=r.fromLatLngToDivPixel(this.map.getBounds().getSouthWest()),n=r.fromLatLngToDivPixel(this.map.getBounds().getNorthEast());this.div.style.left=`${t.x}px`,this.div.style.top=`${n.y}px`}},ye=re;var q=class{constructor(){}clone(r){let t=Array.isArray(r)?[]:{};for(let n in r)t[n]=typeof r[n]=="object"?clone(r[n]):r[n];return t}returnClusterClassObject(r){let t,n;return r>=3?(t="large",n=25):r===2?(t="medium",n=20):(t="small",n=15),{classSize:t,offSet:n}}returnMapProjections(r){let t=new google.maps.LatLngBounds,n=r.getProjection();return{bounds:t,projection:n,topRight:n.fromLatLngToPoint(r.getBounds().getNorthEast()),bottomLeft:n.fromLatLngToPoint(r.getBounds().getSouthWest()),scale:Math.pow(2,r.getZoom())}}returnPointsRaw(r,t){let n=this.returnMapProjections(r);return this.pointsRawLatLng=[],t.map(function(o,a){let s=n.projection.fromLatLngToPoint(new google.maps.LatLng(o.lat,o.lng)),g=(s.x-n.bottomLeft.x)*n.scale,d=(s.y-n.topRight.y)*n.scale;return[g,d,a]})}getCenterPoints(r,t,n){let o=document.getElementById(t),a=o.offsetWidth,s=o.offsetHeight,g=[];for(let d=0;d<=a;d+=n)for(let c=0;c<=s;c+=n){let u=this.searchQuadTree(r,d,c,d+n,c+n),f=u.reduce((i,p)=>[i[0]+p[0],i[1]+p[1]],[0,0]),h=f[0]/u.length,l=f[1]/u.length;h&&l&&g.push([h,l,u])}return g}searchQuadTree(r,t,n,o,a){let s=[];return r.visit((g,d,c,u,f)=>{let h=g.point;return h&&h[0]>=t&&h[0]<o&&h[1]>=n&&h[1]<a&&s.push(h),d>=o||c>=a||u<t||f<n}),s}async getScript(r,t){let n=document.createElement("script");n.async=!0,n.onload=()=>{t&&setTimeout(t,0)},n.src=r,document.head.appendChild(n)}};function be(e){e.sort((n,o)=>n.x!==o.x?n.x-o.x:n.y-o.y);let r=e.length,t=[];for(let n=0;n<2*r;n++){let o=n<r?n:2*r-1-n;for(;t.length>=2&&mt(t[t.length-2],t[t.length-1],e[o]);)t.pop();t.push(e[o])}return t.pop(),t}function mt(e,r,t){let n=(e.x-r.x)*(t.y-r.y)-(e.y-r.y)*(t.x-r.x),o=(e.x-r.x)*(t.x-r.x)+(e.y-r.y)*(t.y-r.y);return n<0||n===0&&o<=0}var J=U(Ce()),ot=U(Qe()),st=U(tt()),it=U(nt()),ee=class{constructor(r,t){this.map=r,this.markers=[],this.markerListeners=[],this.collection=t,this.oms=new it.default(this.map,{markersWontMove:!0,markersWontHide:!0,nearbyDistance:10,keepSpiderfied:!0,legWeight:3,usualLegZIndex:25e3})}print(){this.collection.forEach((r,t)=>{let n=r.lat||r.location.latitude,o=r.lng||r.location.longitude,a=new st.default({id:`marker-${ot.default.generate()}`,position:new google.maps.LatLng(n,o),map:self.map,icon:{path:google.maps.SymbolPath.CIRCLE,scale:0},draggable:!1,labelAnchor:new google.maps.Point(10,10),labelClass:"marker-point",data:r.dataset});this.markers.push(a),this.oms.addMarker(a)}),this.setOmsEvents(),this.setHoverEvents(!1)}publishEvent=(0,J.default)((r,t)=>{GcPs.publish(r,t)},250,{leading:!0,trailing:!1});setOmsEvents(){let r=this;this.oms.addListener("spiderfy",function(t){r.publishEvent("spiderfy",t),r.removeUniversalPointHoverState(),console.log(r.markers.length),r.markers.forEach(function(n){n.setOptions({zIndex:1e3,labelClass:n.labelClass+" fadePins"})}),t.forEach(function(n){r.removeListeners(),r.setHoverEvents(!0),n.setOptions({zIndex:2e3,labelClass:n.labelClass.replace(" fadePins","")})})}),this.oms.addListener("unspiderfy",function(t,n){r.publishEvent("unspiderfy",t),r.removeUniversalPointHoverState(),r.markers.forEach(function(o){o.setOptions({zIndex:1e3,labelClass:o.labelClass.replace(" fadePins","")})}),r.removeListeners(),r.setHoverEvents(!1)})}setHoverEvents=(0,J.default)((r=!1)=>{let t=this;this.setClickEvents(),this.markers.forEach(function(n){let o=n.addListener("mouseover",function({target:s}){GcPs.publish("hover",s),n.setOptions({zIndex:1e4,labelClass:this.labelClass+" PointHoverState"}),r||this.setZIndex(5e3)}),a=n.addListener("mouseout",function(){n.setOptions({zIndex:100,labelClass:this.labelClass.replace(" PointHoverState","")}),r||this.setZIndex(1e3)});t.markerListeners.push(o),t.markerListeners.push(a)})},250);setClickEvents=(0,J.default)(()=>{let r=this;this.markers.forEach(function(t){let n=t.addListener("click",function({target:o}){GcPs.publish("click",o)});r.markerListeners.push(n)})},250);removeUniversalPointHoverState(){this.markers.forEach((r,t)=>{r.setOptions({zIndex:100,labelClass:"marker-point"})})}removeListeners(){for(let r=0;r<this.markerListeners.length;r++)google.maps.event.removeListener(this.markerListeners[r]);this.markerListeners=[]}remove(){this.removeListeners();for(var r=0;r<this.markers.length;r++)this.markers[r].setMap(null)}};var te=U(at()),R=new q;window.GcPs=te.default;var lt=class{map;collection;mapContainer="map";clusterRange=200;threshold=200;clusterRgba="34, 34, 34, 1";clusterBorder="5px solid #ccc";clusterFontColor="#FBBDC7";polygonStrokeColor="#222";polygonStrokeOpacity="0.5";polygonStrokeWeight="4";polygonFillColor="#222";polygonFillOpacity="0.3";overlay;mapContainerElem;points;polygon;helpers;constructor(r){R.getScript("https://d3js.org/d3.v3.min.js");for(let t in r)this[t]=r[t];this.createOverlay(),this.setMapEvents()}setMapEvents(){google.maps.event.addListener(this.map,"idle",()=>{this.collection&&(this.createOverlay(),this.removePolygon(),this.removeElements(),this.print())}),google.maps.event.addListener(this.map,"dragstart",()=>{this.removePolygon(),this.removeElements()}),google.maps.event.addListener(this.map,"zoom_changed",()=>{this.removePolygon(),this.removeElements()})}setCollection(r){this.collection=r;let t=setInterval(()=>{window.d3&&(clearInterval(t),this.print())},10)}createOverlay(){this.overlay&&this.overlay.setMap(null),this.overlay=new ye(this.map),this.overlay.setMap(this.map)}print(){let r=R.returnPointsRaw(this.map,this.collection),t=window.d3.geom.quadtree()(r),n=R.getCenterPoints(t,this.mapContainer,this.clusterRange);this.points?.remove(),this.waitForMapContainer(o=>{this.paint(n)})}waitForMapContainer(r){this.mapContainerElem=document.querySelector("#GoogleClustrOverlay"),this.mapContainerElem?r(this.mapContainerElem):setTimeout(()=>this.waitForMapContainer(r),10)}removeElements(){for(var r=document.getElementsByClassName("point-cluster");r.length>0;)r[0]?.parentNode?.removeChild(r[0])}paint(r){let t=this.checkIfLatLngInBounds();t.length<=this.threshold?(this.removeOverlay(),this.points=new ee(this.map,t),this.points.print(),this.publishData(t.length,t)):(this.paintClustersToCanvas(r),this.publishData(t.length))}removeOverlay(){this.overlay.setMap(null)}publishData(r,t){te.default.publish("count",r),t&&te.default.publish("show",t)}paintClustersToCanvas(r){let t=document.createDocumentFragment();r.forEach((n,o)=>{let a=n[2].length,s=a.toString().length,g=document.createElement("div");g.className=`point-cluster ${R.returnClusterClassObject(s).classSize}`,g.style.backgroundColor=`rgba(${this.clusterRgba})`,g.style.color=this.clusterFontColor,g.dataset.positionid=o.toString();let d=n[2].map(i=>i[2]),c=d.map(i=>{let p=this.collection[i];return new google.maps.LatLng(p.lat,p.lng)}),u=R.returnMapProjections(this.map);c.forEach(i=>{u.bounds.extend(i)});let f=u.projection.fromLatLngToPoint(u.bounds.getCenter()),h=(f.x-u.bottomLeft.x)*u.scale,l=(f.y-u.topRight.y)*u.scale;g.style.left=`${h-R.returnClusterClassObject(s).offSet}px`,g.style.top=`${l-R.returnClusterClassObject(s).offSet}px`,g.dataset.latlngids=d.join(","),g.innerHTML=a.toString(),t.appendChild(g),this.setClusterEvents(g)}),this.mapContainerElem.appendChild(t)}setClusterEvents(r){r.onmouseover=()=>{this.showPolygon(r,this.collection,this.map)},r.onmouseout=()=>{this.removePolygon()},r.onclick=()=>{this.zoomToFit(r)}}zoomToFit(r){let t=r?.dataset?.latlngids?.split(",");if(!t)return;let n=t.map(g=>{let d=this.collection[parseInt(g)];return new google.maps.LatLng(d.lat,d.lng)}),o=new google.maps.LatLngBounds;n.forEach(g=>o.extend(g));let a=o.getCenter(),s=this.getBoundsZoomLevel(o);requestAnimationFrame(()=>{this.map.setCenter(a),this.map.setZoom(s)})}getBoundsZoomLevel(r){let t={height:256,width:256},n=22,o=document.querySelector(`#${this.mapContainer}`),a={height:o.clientHeight,width:o.clientWidth};function s(p){let m=Math.sin(p*Math.PI/180),v=Math.log((1+m)/(1-m))/2;return Math.max(Math.min(v,Math.PI),-Math.PI)/2}function g(p,m,v){return Math.floor(Math.log(p/m/v)/Math.LN2)}let d=r.getNorthEast(),c=r.getSouthWest(),u=(s(d.lat())-s(c.lat()))/Math.PI,f=d.lng()-c.lng(),h=(f<0?f+360:f)/360,l=g(a.height,t.height,u),i=g(a.width,t.width,h);return Math.min(l,i,n)}checkIfLatLngInBounds(){return this.collection.filter(t=>{let n=t.lat||t.location.latitude,o=t.lng||t.location.longitude,a=new google.maps.LatLng(n,o);return this.map.getBounds().contains(a)})}showPolygon(r,t,n){let a=(r?.dataset?.latlngids?.split(",")||[]).concat(r?.dataset?.latlngids?.split(",")[0]).map(d=>({x:t[d].lat,y:t[d].lng})),g=be(a).map(d=>({lat:d.x,lng:d.y}));this.polygon=new google.maps.Polygon({paths:g,strokeColor:this.polygonStrokeColor,strokeOpacity:this.polygonStrokeOpacity,strokeWeight:this.polygonStrokeWeight,fillColor:this.polygonFillColor,fillOpacity:this.polygonFillOpacity}),this.polygon.setMap(n)}removePolygon(){this.polygon&&this.polygon.setMap(null)}};export{lt as GoogleClustr}; /*! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ //# sourceMappingURL=index.js.map