New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@2gis/mapgl-clusterer

Package Overview
Dependencies
Maintainers
6
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@2gis/mapgl-clusterer - npm Package Compare versions

Comparing version

to
2.4.2

2

dist/clustering.js

@@ -16,2 +16,2 @@ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var n in o)("object"==typeof exports?exports:t)[n]=o[n]}}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/",o(o.s=1)}([function(t,e,o){t.exports=function(){"use strict";function t(o,n,r,i,s,a){if(!(s-i<=r)){var u=i+s>>1;!function t(o,n,r,i,s,a){for(;s>i;){if(s-i>600){var u=s-i+1,l=r-i+1,p=Math.log(u),c=.5*Math.exp(2*p/3),h=.5*Math.sqrt(p*c*(u-c)/u)*(l-u/2<0?-1:1),f=Math.max(i,Math.floor(r-l*c/u+h)),d=Math.min(s,Math.floor(r+(u-l)*c/u+h));t(o,n,r,f,d,a)}var m=n[2*r+a],v=i,g=s;for(e(o,n,i,r),n[2*s+a]>m&&e(o,n,i,s);v<g;){for(e(o,n,v,g),v++,g--;n[2*v+a]<m;)v++;for(;n[2*g+a]>m;)g--}n[2*i+a]===m?e(o,n,i,g):(g++,e(o,n,g,s)),g<=r&&(i=g+1),r<=g&&(s=g-1)}}(o,n,u,i,s,a%2),t(o,n,r,i,u-1,a+1),t(o,n,r,u+1,s,a+1)}}function e(t,e,n,r){o(t,n,r),o(e,2*n,2*r),o(e,2*n+1,2*r+1)}function o(t,e,o){var n=t[e];t[e]=t[o],t[o]=n}function n(t,e,o,n){var r=t-o,i=e-n;return r*r+i*i}var r=function(t){return t[0]},i=function(t){return t[1]},s=function(e,o,n,s,a){void 0===o&&(o=r),void 0===n&&(n=i),void 0===s&&(s=64),void 0===a&&(a=Float64Array),this.nodeSize=s,this.points=e;for(var u=e.length<65536?Uint16Array:Uint32Array,l=this.ids=new u(e.length),p=this.coords=new a(2*e.length),c=0;c<e.length;c++)l[c]=c,p[2*c]=o(e[c]),p[2*c+1]=n(e[c]);t(l,p,s,0,l.length-1,0)};s.prototype.range=function(t,e,o,n){return function(t,e,o,n,r,i,s){for(var a,u,l=[0,t.length-1,0],p=[];l.length;){var c=l.pop(),h=l.pop(),f=l.pop();if(h-f<=s)for(var d=f;d<=h;d++)a=e[2*d],u=e[2*d+1],a>=o&&a<=r&&u>=n&&u<=i&&p.push(t[d]);else{var m=Math.floor((f+h)/2);a=e[2*m],u=e[2*m+1],a>=o&&a<=r&&u>=n&&u<=i&&p.push(t[m]);var v=(c+1)%2;(0===c?o<=a:n<=u)&&(l.push(f),l.push(m-1),l.push(v)),(0===c?r>=a:i>=u)&&(l.push(m+1),l.push(h),l.push(v))}}return p}(this.ids,this.coords,t,e,o,n,this.nodeSize)},s.prototype.within=function(t,e,o){return function(t,e,o,r,i,s){for(var a=[0,t.length-1,0],u=[],l=i*i;a.length;){var p=a.pop(),c=a.pop(),h=a.pop();if(c-h<=s)for(var f=h;f<=c;f++)n(e[2*f],e[2*f+1],o,r)<=l&&u.push(t[f]);else{var d=Math.floor((h+c)/2),m=e[2*d],v=e[2*d+1];n(m,v,o,r)<=l&&u.push(t[d]);var g=(p+1)%2;(0===p?o-i<=m:r-i<=v)&&(a.push(h),a.push(d-1),a.push(g)),(0===p?o+i>=m:r+i>=v)&&(a.push(d+1),a.push(c),a.push(g))}}return u}(this.ids,this.coords,t,e,o,this.nodeSize)};var a={minZoom:0,maxZoom:16,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:function(t){return t}},u=function(t){this.options=m(Object.create(a),t),this.trees=new Array(this.options.maxZoom+1)};function l(t,e,o,n,r){return{x:t,y:e,zoom:1/0,id:o,parentId:-1,numPoints:n,properties:r}}function p(t,e){var o=t.geometry.coordinates,n=o[0],r=o[1];return{x:f(n),y:d(r),zoom:1/0,index:e,parentId:-1}}function c(t){return{type:"Feature",id:t.id,properties:h(t),geometry:{type:"Point",coordinates:[(n=t.x,360*(n-.5)),(e=t.y,o=(180-360*e)*Math.PI/180,360*Math.atan(Math.exp(o))/Math.PI-90)]}};var e,o,n}function h(t){var e=t.numPoints,o=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return m(m({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:o})}function f(t){return t/360+.5}function d(t){var e=Math.sin(t*Math.PI/180),o=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return o<0?0:o>1?1:o}function m(t,e){for(var o in e)t[o]=e[o];return t}function v(t){return t.x}function g(t){return t.y}return u.prototype.load=function(t){var e=this.options,o=e.log,n=e.minZoom,r=e.maxZoom,i=e.nodeSize;o&&console.time("total time");var a="prepare "+t.length+" points";o&&console.time(a),this.points=t;for(var u=[],l=0;l<t.length;l++)t[l].geometry&&u.push(p(t[l],l));this.trees[r+1]=new s(u,v,g,i,Float32Array),o&&console.timeEnd(a);for(var c=r;c>=n;c--){var h=+Date.now();u=this._cluster(u,c),this.trees[c]=new s(u,v,g,i,Float32Array),o&&console.log("z%d: %d clusters in %dms",c,u.length,+Date.now()-h)}return o&&console.timeEnd("total time"),this},u.prototype.getClusters=function(t,e){var o=((t[0]+180)%360+360)%360-180,n=Math.max(-90,Math.min(90,t[1])),r=180===t[2]?180:((t[2]+180)%360+360)%360-180,i=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)o=-180,r=180;else if(o>r){var s=this.getClusters([o,n,180,i],e),a=this.getClusters([-180,n,r,i],e);return s.concat(a)}for(var u=this.trees[this._limitZoom(e)],l=[],p=0,h=u.range(f(o),d(i),f(r),d(n));p<h.length;p+=1){var m=h[p],v=u.points[m];l.push(v.numPoints?c(v):this.points[v.index])}return l},u.prototype.getChildren=function(t){var e=this._getOriginId(t),o=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[o];if(!r)throw new Error(n);var i=r.points[e];if(!i)throw new Error(n);for(var s=this.options.radius/(this.options.extent*Math.pow(2,o-1)),a=[],u=0,l=r.within(i.x,i.y,s);u<l.length;u+=1){var p=l[u],h=r.points[p];h.parentId===t&&a.push(h.numPoints?c(h):this.points[h.index])}if(0===a.length)throw new Error(n);return a},u.prototype.getLeaves=function(t,e,o){e=e||10,o=o||0;var n=[];return this._appendLeaves(n,t,e,o,0),n},u.prototype.getTile=function(t,e,o){var n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),i=this.options,s=i.extent,a=i.radius/s,u=(o-a)/r,l=(o+1+a)/r,p={features:[]};return this._addTileFeatures(n.range((e-a)/r,u,(e+1+a)/r,l),n.points,e,o,r,p),0===e&&this._addTileFeatures(n.range(1-a/r,u,1,l),n.points,r,o,r,p),e===r-1&&this._addTileFeatures(n.range(0,u,a/r,l),n.points,-1,o,r,p),p.features.length?p:null},u.prototype.getClusterExpansionZoom=function(t){for(var e=this._getOriginZoom(t)-1;e<=this.options.maxZoom;){var o=this.getChildren(t);if(e++,1!==o.length)break;t=o[0].properties.cluster_id}return e},u.prototype._appendLeaves=function(t,e,o,n,r){for(var i=0,s=this.getChildren(e);i<s.length;i+=1){var a=s[i],u=a.properties;if(u&&u.cluster?r+u.point_count<=n?r+=u.point_count:r=this._appendLeaves(t,u.cluster_id,o,n,r):r<n?r++:t.push(a),t.length===o)break}return r},u.prototype._addTileFeatures=function(t,e,o,n,r,i){for(var s=0,a=t;s<a.length;s+=1){var u=e[a[s]],l=u.numPoints,p={type:1,geometry:[[Math.round(this.options.extent*(u.x*r-o)),Math.round(this.options.extent*(u.y*r-n))]],tags:l?h(u):this.points[u.index].properties},c=void 0;l?c=u.id:this.options.generateId?c=u.index:this.points[u.index].id&&(c=this.points[u.index].id),void 0!==c&&(p.id=c),i.features.push(p)}},u.prototype._limitZoom=function(t){return Math.max(this.options.minZoom,Math.min(t,this.options.maxZoom+1))},u.prototype._cluster=function(t,e){for(var o=[],n=this.options,r=n.radius,i=n.extent,s=n.reduce,a=r/(i*Math.pow(2,e)),u=0;u<t.length;u++){var p=t[u];if(!(p.zoom<=e)){p.zoom=e;for(var c=this.trees[e+1],h=c.within(p.x,p.y,a),f=p.numPoints||1,d=p.x*f,m=p.y*f,v=s&&f>1?this._map(p,!0):null,g=(u<<5)+(e+1)+this.points.length,y=0,b=h;y<b.length;y+=1){var _=b[y],x=c.points[_];if(!(x.zoom<=e)){x.zoom=e;var M=x.numPoints||1;d+=x.x*M,m+=x.y*M,f+=M,x.parentId=g,s&&(v||(v=this._map(p,!0)),s(v,this._map(x)))}}1===f?o.push(p):(p.parentId=g,o.push(l(d/f,m/f,g,f,v)))}}return o},u.prototype._getOriginId=function(t){return t-this.points.length>>5},u.prototype._getOriginZoom=function(t){return(t-this.points.length)%32},u.prototype._map=function(t,e){if(t.numPoints)return e?m({},t.properties):t.properties;var o=this.points[t.index].properties,n=this.options.map(o);return e&&n===o?m({},n):n},u}()},function(t,e,o){"use strict";o.r(e),o.d(e,"Clusterer",(function(){return m}));

***************************************************************************** */
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};var r=function(){return(r=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};var i=function(){function t(){this.events={}}return t.prototype.on=function(t,e){var o=this.events[t];return o||(o=this.events[t]=[]),o.push(e),this},t.prototype.once=function(t,e){var o=this,n=function(r){o.off(t,n),e.call(o,r)};return this.on(t,n),this},t.prototype.off=function(t,e){var o=this.events[t];if(!o)return this;var n=o.indexOf(e);return-1!==n&&o.splice(n,1),this},t.prototype.emit=function(t,e){var o=this.events[t];if(!o)return this;for(var n=o.slice(),r=0;r<n.length;r++)n[r].call(this,e);return this},t}(),s="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzMCIgdmlld0JveD0iMCAwIDMwIDMwIj48Y2lyY2xlIGZpbGw9IiM0OGQ5NWQiIGN4PSIxNSIgY3k9IjE1IiByPSIxNSIvPjwvc3ZnPg==",a=["click","mousemove","mouseover","mouseout","mousedown","mouseup","touchstart","touchend"];function u(t,e,o){var n=t.getBoundingClientRect();return[e-n.left-t.clientLeft,o-n.top-t.clientTop]}function l(t,e){return function(t){return void 0!==t.screenX}(e)?u(t,e.clientX,e.clientY):u(t,e.changedTouches[0].clientX,e.changedTouches[0].clientY)}var p=o(0),c=1,h=0,f=[15,43],d={minZoom:-1/0,maxZoom:1/0,color:"#000000",fontSize:18,haloRadius:0,haloColor:"#ffffff",letterSpacing:0,lineHeight:1.2,offset:[0,0],relativeAnchor:[.5,.5]},m=function(t){function e(o,n){var i,s;void 0===n&&(n={});var a=t.call(this)||this;a._updateVisibleObjects=function(){var t=a._getVisibleObjects();a.markers.forEach((function(t){t.hide()})),a.clusters.forEach((function(t){t.marker.hide()})),t.forEach((function(t){if(function(t){return t.properties.cluster}(t)){var e=t.properties.cluster_id,o=a.clusters.get(e);o?o.marker.show():a._createCluster(e,t.geometry.coordinates,t.properties.point_count)}else{var n=t.properties.index,r=a.markers.get(n);r?r.show():a._createMarker(n,t.geometry.coordinates)}}))},a._throttleUpdateVisibleObjects=function(t,e){var o,n;function r(){o=!1,n&&(i.apply(void 0,n),n=!1)}function i(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];o?n=i:(t.apply(void 0,i),setTimeout(r,e),o=!0)}return i}(a._updateVisibleObjects,100);var u=null!==(i=n.radius)&&void 0!==i?i:e.options.radius,l=null!==(s=n.disableClusteringAtZoom)&&void 0!==s?s:e.options.disableClusteringAtZoom,c=e.options.clusterStyle;return n.clusterStyle&&(c="function"==typeof n.clusterStyle?n.clusterStyle:r(r({},c),n.clusterStyle)),a.options={radius:u,clusterStyle:c,disableClusteringAtZoom:l},a.map=o,a.inputMarkers=[],a.supercluster=new p({minZoom:0,maxZoom:Math.floor(a.options.disableClusteringAtZoom),radius:a.options.radius}),a.markers=new Map,a.clusters=new Map,a.map.on("move",a._throttleUpdateVisibleObjects),a.map.on("resize",a._throttleUpdateVisibleObjects),a}return function(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,t),e.prototype.load=function(t){this._clear(),this.inputMarkers=t,this.supercluster.load(function(t){return t.map((function(t,e){return{type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{index:e,cluster:!1}}}))}(t)),this._updateVisibleObjects()},e.prototype.destroy=function(){this._clear(),this.map.off("move",this._throttleUpdateVisibleObjects),this.map.off("resize",this._throttleUpdateVisibleObjects)},e.prototype.setClusterStyle=function(t,o){var n=this.clusters.get(t);if(n){var i=n.target.data.length;"function"==typeof o&&(o=r(r({},e.options.clusterStyle),o(i,n.target))),"webgl"===n.type?void 0!==o.type&&"webgl"!==o.type||(n.marker.setIcon({icon:o.icon||s,size:o.size,anchor:v(o.icon,o.anchor)}),o.hoverIcon?n.marker.setHoverIcon({icon:o.hoverIcon,size:o.hoverSize,anchor:o.hoverAnchor}):n.marker.setHoverIcon(),n.marker.setLabel(g(i,o))):"html"===n.type&&"html"===o.type&&(n.marker.setContent(o.html),n.marker.setAnchor(o.anchor||[0,0]))}},e.prototype.resetClusterStyle=function(t){this.setClusterStyle(t,this.options.clusterStyle)},e.prototype._dangerouslyUpdateVisibleObjects=function(){this._updateVisibleObjects()},e.prototype.getClusterExpansionZoom=function(t){return this.supercluster.getClusterExpansionZoom(t)},e.prototype._clear=function(){this.markers.forEach((function(t){t.destroy()})),this.clusters.forEach((function(t){t.marker.destroy()})),this.markers.clear(),this.clusters.clear(),this.supercluster.load([]),this.inputMarkers=[]},e.prototype._getVisibleObjects=function(){var t=this.map.getZoom(),e=t<this.options.disableClusteringAtZoom?Math.floor(t):Math.ceil(t)+1,o=this._getBounds();return this.supercluster.getClusters(o,e)},e.prototype._getBounds=function(){var t=this.map.getSize(),e=.06*t[0],o=.06*t[1],n=this.map.unproject([-e,t[1]+o]),r=this.map.unproject([t[0]+e,t[1]+o]),i=this.map.unproject([t[0]+e,-o]),s=this.map.unproject([-e,-o]);return[Math.min(n[0],r[0],i[0],s[0]),Math.min(n[1],r[1],i[1],s[1]),Math.max(n[0],r[0],i[0],s[0]),Math.max(n[1],r[1],i[1],s[1])]},e.prototype.isMapglMarker=function(t){return!t.type||"webgl"===t.type},e.prototype._createMarker=function(t,e){var o=this.inputMarkers[t],n=this.isMapglMarker(o)?this._createMapglMarker(r(r({},o),{coordinates:e})):this._createHtmlMarker(r(r({},o),{coordinates:e}));this.markers.set(t,n)},e.prototype._createMapglMarker=function(t){var e,o,n,r,i,s,u,l,p=this,h=t.coordinates,m=t.icon,v=t.size,g=t.anchor,y=t.hoverIcon,b=t.hoverSize,_=t.hoverAnchor,x=t.label,M=x?{text:x.text,image:x.image,minZoom:null!==(e=x.minZoom)&&void 0!==e?e:d.minZoom,maxZoom:null!==(o=x.maxZoom)&&void 0!==o?o:d.maxZoom,color:x.color||d.color,fontSize:null!==(n=x.fontSize)&&void 0!==n?n:d.fontSize,haloRadius:null!==(r=x.haloRadius)&&void 0!==r?r:d.haloRadius,haloColor:x.haloColor||d.haloColor,letterSpacing:null!==(i=x.letterSpacing)&&void 0!==i?i:d.letterSpacing,lineHeight:null!==(s=x.lineHeight)&&void 0!==s?s:d.lineHeight,zIndex:c+1e-5,offset:(null!==(u=x.offset)&&void 0!==u?u:null===(l=x.anchor)||void 0===l?void 0:l.map((function(t){return-t})))||d.offset,relativeAnchor:x.relativeAnchor||d.relativeAnchor}:void 0,w=new mapgl.Marker(this.map,{coordinates:h,icon:m,size:v,anchor:void 0!==m?g:f,hoverIcon:y,hoverSize:b,hoverAnchor:_,label:M,zIndex:c}),S={type:"marker",data:t};return a.forEach((function(t){return w.on(t,(function(e){var o={originalEvent:e.originalEvent,lngLat:e.lngLat,point:e.point,target:S};p.emit(t,o)}))})),w},e.prototype._bindHtmlMarkerEvents=function(t,e,o){var n=this,r=this.map.getContainer(),i=e._impl.dangerouslyGetRootElement();a.forEach((function(e){return i.addEventListener(e,(function(i){var s={originalEvent:i,lngLat:t,point:l(r,i),target:o};n.emit(e,s)}),{passive:!0})}))},e.prototype._createHtmlMarker=function(t){var e=t.coordinates,o=t.html,n=t.anchor,r=t.minZoom,i=t.maxZoom,s=t.zIndex,a=t.preventMapInteractions,u=new mapgl.HtmlMarker(this.map,{coordinates:e,html:o,anchor:n,minZoom:r,maxZoom:i,preventMapInteractions:a,zIndex:null!=s?s:c}),l={type:"marker",data:t};this._bindHtmlMarkerEvents(e,u,l);var p=u.getContent();return{show:function(){p.hidden&&(p.hidden=!1)},hide:function(){p.hidden||(p.hidden=!0)},destroy:function(){u.destroy()},setContent:function(t){u.setContent(t)},setAnchor:function(t){u.setAnchor(t)}}},e.prototype.isWebglClusterStyle=function(t){return!t.type||"webgl"===t.type},e.prototype._createCluster=function(t,o,n){var i=this,s=this.supercluster.getLeaves(t,1/0).map((function(t){return i.inputMarkers[t.properties.index]})),a={id:t,type:"cluster",data:s},u="function"==typeof this.options.clusterStyle?r(r({},e.options.clusterStyle),this.options.clusterStyle(s.length,a)):this.options.clusterStyle;if(this.isWebglClusterStyle(u)){var l=this._createWebGLCluster(o,n,u,a);this.clusters.set(t,{type:"webgl",coordinates:o,marker:l,target:a})}else{l=this._createHtmlCluster(o,n,u,a);this.clusters.set(t,{type:"html",coordinates:o,marker:l,target:a})}},e.prototype._createWebGLCluster=function(t,e,o,n){var r=this,i=new mapgl.Marker(this.map,{coordinates:t,zIndex:h,icon:o.icon||s,size:o.size,anchor:v(o.icon,o.anchor),hoverIcon:o.hoverIcon,hoverSize:o.hoverSize,hoverAnchor:o.hoverAnchor,label:g(e,o)});return a.forEach((function(t){return i.on(t,(function(e){var o={originalEvent:e.originalEvent,lngLat:e.lngLat,point:e.point,target:n};r.emit(t,o)}))})),i},e.prototype._createHtmlCluster=function(t,e,o,n){var r=o.html,i=o.anchor,s=o.minZoom,a=o.maxZoom,u=o.zIndex,l=o.preventMapInteractions,p=new mapgl.HtmlMarker(this.map,{coordinates:t,html:r||String(e),anchor:i,minZoom:s,maxZoom:a,preventMapInteractions:l,zIndex:null!=u?u:h});this._bindHtmlMarkerEvents(t,p,n);var c=p.getContent();return{show:function(){c.hidden&&(c.hidden=!1)},hide:function(){c.hidden||(c.hidden=!0)},destroy:function(){p.destroy()},setContent:function(t){p.setContent(t)},setAnchor:function(t){p.setAnchor(t)}}},e.options={radius:80,disableClusteringAtZoom:20,clusterStyle:{icon:s,labelColor:"#000000",labelFontSize:14,labelAnchor:[0,0],labelText:void 0}},e}(i);function v(t,e){return void 0!==t?e:void 0}function g(t,e){var o,n,r,i,s,a;return{text:null!==(o=e.labelText)&&void 0!==o?o:String(t),color:e.labelColor||d.color,fontSize:null!==(n=e.labelFontSize)&&void 0!==n?n:d.fontSize,haloRadius:null!==(r=e.labelHaloRadius)&&void 0!==r?r:d.haloRadius,haloColor:e.labelHaloColor||d.haloColor,letterSpacing:null!==(i=e.labelLetterSpacing)&&void 0!==i?i:d.letterSpacing,anchor:e.labelAnchor,offset:(null!==(s=e.labelOffset)&&void 0!==s?s:null===(a=e.labelAnchor)||void 0===a?void 0:a.map((function(t){return-t})))||d.offset,relativeAnchor:e.labelRelativeAnchor||d.relativeAnchor,image:e.labelImage,zIndex:h+1e-5,minZoom:d.minZoom,maxZoom:d.maxZoom,lineHeight:d.lineHeight}}"undefined"!=typeof window&&("mapgl"in window?mapgl.Clusterer=m:(window.__mapglPlugins||(window.__mapglPlugins={}),window.__mapglPlugins.Clusterer=m))}])}));
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};var r=function(){return(r=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};var i=function(){function t(){this.events={}}return t.prototype.on=function(t,e){var o=this.events[t];return o||(o=this.events[t]=[]),o.push(e),this},t.prototype.once=function(t,e){var o=this,n=function(r){o.off(t,n),e.call(o,r)};return this.on(t,n),this},t.prototype.off=function(t,e){var o=this.events[t];if(!o)return this;var n=o.indexOf(e);return-1!==n&&o.splice(n,1),this},t.prototype.emit=function(t,e){var o=this.events[t];if(!o)return this;for(var n=o.slice(),r=0;r<n.length;r++)n[r].call(this,e);return this},t}(),s="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzMCIgdmlld0JveD0iMCAwIDMwIDMwIj48Y2lyY2xlIGZpbGw9IiM0OGQ5NWQiIGN4PSIxNSIgY3k9IjE1IiByPSIxNSIvPjwvc3ZnPg==",a=["click","mousemove","mouseover","mouseout","mousedown","mouseup","touchstart","touchend"];function u(t,e,o){var n=t.getBoundingClientRect();return[e-n.left-t.clientLeft,o-n.top-t.clientTop]}function l(t,e){return function(t){return void 0!==t.screenX}(e)?u(t,e.clientX,e.clientY):u(t,e.changedTouches[0].clientX,e.changedTouches[0].clientY)}var p=o(0),c=1,h=0,f=[15,43],d={minZoom:-1/0,maxZoom:1/0,color:"#000000",fontSize:18,haloRadius:0,haloColor:"#ffffff",letterSpacing:0,lineHeight:1.2,offset:[0,0],relativeAnchor:[.5,.5]},m=function(t){function e(o,n){var i,s;void 0===n&&(n={});var a=t.call(this)||this;a._updateVisibleObjects=function(){var t=a._getVisibleObjects();a.markers.forEach((function(t){t.hide()})),a.clusters.forEach((function(t){t.marker.hide()})),t.forEach((function(t){if(function(t){return t.properties.cluster}(t)){var e=t.properties.cluster_id,o=a.clusters.get(e);o?o.marker.show():a._createCluster(e,t.geometry.coordinates,t.properties.point_count)}else{var n=t.properties.index,r=a.markers.get(n);r?r.show():a._createMarker(n,t.geometry.coordinates)}}))},a._throttleUpdateVisibleObjects=function(t,e){var o,n;function r(){o=!1,n&&(i.apply(void 0,n),n=!1)}function i(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];o?n=i:(t.apply(void 0,i),setTimeout(r,e),o=!0)}return i}(a._updateVisibleObjects,100);var u=null!==(i=n.radius)&&void 0!==i?i:e.options.radius,l=null!==(s=n.disableClusteringAtZoom)&&void 0!==s?s:e.options.disableClusteringAtZoom,c=e.options.clusterStyle;return n.clusterStyle&&(c="function"==typeof n.clusterStyle?n.clusterStyle:r(r({},c),n.clusterStyle)),a.options={radius:u,clusterStyle:c,disableClusteringAtZoom:l},a.map=o,a.inputMarkers=[],a.supercluster=new p({minZoom:0,maxZoom:Math.floor(a.options.disableClusteringAtZoom),radius:a.options.radius}),a.supercluster.load([]),a.markers=new Map,a.clusters=new Map,a.map.on("move",a._throttleUpdateVisibleObjects),a.map.on("resize",a._throttleUpdateVisibleObjects),a}return function(t,e){function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,t),e.prototype.load=function(t){this._clear(),this.inputMarkers=t,this.supercluster.load(function(t){return t.map((function(t,e){return{type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{index:e,cluster:!1}}}))}(t)),this._updateVisibleObjects()},e.prototype.destroy=function(){this._clear(),this.map.off("move",this._throttleUpdateVisibleObjects),this.map.off("resize",this._throttleUpdateVisibleObjects)},e.prototype.setClusterStyle=function(t,o){var n=this.clusters.get(t);if(n){var i=n.target.data.length;"function"==typeof o&&(o=r(r({},e.options.clusterStyle),o(i,n.target))),"webgl"===n.type?void 0!==o.type&&"webgl"!==o.type||(n.marker.setIcon({icon:o.icon||s,size:o.size,anchor:v(o.icon,o.anchor)}),o.hoverIcon?n.marker.setHoverIcon({icon:o.hoverIcon,size:o.hoverSize,anchor:o.hoverAnchor}):n.marker.setHoverIcon(),n.marker.setLabel(g(i,o))):"html"===n.type&&"html"===o.type&&(n.marker.setContent(o.html),n.marker.setAnchor(o.anchor||[0,0]))}},e.prototype.resetClusterStyle=function(t){this.setClusterStyle(t,this.options.clusterStyle)},e.prototype._dangerouslyUpdateVisibleObjects=function(){this._updateVisibleObjects()},e.prototype.getClusterExpansionZoom=function(t){return this.supercluster.getClusterExpansionZoom(t)},e.prototype._clear=function(){this.markers.forEach((function(t){t.destroy()})),this.clusters.forEach((function(t){t.marker.destroy()})),this.markers.clear(),this.clusters.clear(),this.supercluster.load([]),this.inputMarkers=[]},e.prototype._getVisibleObjects=function(){var t=this.map.getZoom(),e=t<this.options.disableClusteringAtZoom?Math.floor(t):Math.ceil(t)+1,o=this._getBounds();return this.supercluster.getClusters(o,e)},e.prototype._getBounds=function(){var t=this.map.getSize(),e=.06*t[0],o=.06*t[1],n=this.map.unproject([-e,t[1]+o]),r=this.map.unproject([t[0]+e,t[1]+o]),i=this.map.unproject([t[0]+e,-o]),s=this.map.unproject([-e,-o]);return[Math.min(n[0],r[0],i[0],s[0]),Math.min(n[1],r[1],i[1],s[1]),Math.max(n[0],r[0],i[0],s[0]),Math.max(n[1],r[1],i[1],s[1])]},e.prototype.isMapglMarker=function(t){return!t.type||"webgl"===t.type},e.prototype._createMarker=function(t,e){var o=this.inputMarkers[t],n=this.isMapglMarker(o)?this._createMapglMarker(r(r({},o),{coordinates:e})):this._createHtmlMarker(r(r({},o),{coordinates:e}));this.markers.set(t,n)},e.prototype._createMapglMarker=function(t){var e,o,n,r,i,s,u,l,p=this,h=t.coordinates,m=t.icon,v=t.size,g=t.anchor,y=t.hoverIcon,b=t.hoverSize,_=t.hoverAnchor,x=t.label,M=x?{text:x.text,image:x.image,minZoom:null!==(e=x.minZoom)&&void 0!==e?e:d.minZoom,maxZoom:null!==(o=x.maxZoom)&&void 0!==o?o:d.maxZoom,color:x.color||d.color,fontSize:null!==(n=x.fontSize)&&void 0!==n?n:d.fontSize,haloRadius:null!==(r=x.haloRadius)&&void 0!==r?r:d.haloRadius,haloColor:x.haloColor||d.haloColor,letterSpacing:null!==(i=x.letterSpacing)&&void 0!==i?i:d.letterSpacing,lineHeight:null!==(s=x.lineHeight)&&void 0!==s?s:d.lineHeight,zIndex:c+1e-5,offset:(null!==(u=x.offset)&&void 0!==u?u:null===(l=x.anchor)||void 0===l?void 0:l.map((function(t){return-t})))||d.offset,relativeAnchor:x.relativeAnchor||d.relativeAnchor}:void 0,w=new mapgl.Marker(this.map,{coordinates:h,icon:m,size:v,anchor:void 0!==m?g:f,hoverIcon:y,hoverSize:b,hoverAnchor:_,label:M,zIndex:c}),S={type:"marker",data:t};return a.forEach((function(t){return w.on(t,(function(e){var o={originalEvent:e.originalEvent,lngLat:e.lngLat,point:e.point,target:S};p.emit(t,o)}))})),w},e.prototype._bindHtmlMarkerEvents=function(t,e,o){var n=this,r=this.map.getContainer(),i=e._impl.dangerouslyGetRootElement();a.forEach((function(e){return i.addEventListener(e,(function(i){var s={originalEvent:i,lngLat:t,point:l(r,i),target:o};n.emit(e,s)}),{passive:!0})}))},e.prototype._createHtmlMarker=function(t){var e=t.coordinates,o=t.html,n=t.anchor,r=t.minZoom,i=t.maxZoom,s=t.zIndex,a=t.preventMapInteractions,u=new mapgl.HtmlMarker(this.map,{coordinates:e,html:o,anchor:n,minZoom:r,maxZoom:i,preventMapInteractions:a,zIndex:null!=s?s:c}),l={type:"marker",data:t};this._bindHtmlMarkerEvents(e,u,l);var p=u.getContent();return{show:function(){p.hidden&&(p.hidden=!1)},hide:function(){p.hidden||(p.hidden=!0)},destroy:function(){u.destroy()},setContent:function(t){u.setContent(t)},setAnchor:function(t){u.setAnchor(t)}}},e.prototype.isWebglClusterStyle=function(t){return!t.type||"webgl"===t.type},e.prototype._createCluster=function(t,o,n){var i=this,s=this.supercluster.getLeaves(t,1/0).map((function(t){return i.inputMarkers[t.properties.index]})),a={id:t,type:"cluster",data:s},u="function"==typeof this.options.clusterStyle?r(r({},e.options.clusterStyle),this.options.clusterStyle(s.length,a)):this.options.clusterStyle;if(this.isWebglClusterStyle(u)){var l=this._createWebGLCluster(o,n,u,a);this.clusters.set(t,{type:"webgl",coordinates:o,marker:l,target:a})}else{l=this._createHtmlCluster(o,n,u,a);this.clusters.set(t,{type:"html",coordinates:o,marker:l,target:a})}},e.prototype._createWebGLCluster=function(t,e,o,n){var r=this,i=new mapgl.Marker(this.map,{coordinates:t,zIndex:h,icon:o.icon||s,size:o.size,anchor:v(o.icon,o.anchor),hoverIcon:o.hoverIcon,hoverSize:o.hoverSize,hoverAnchor:o.hoverAnchor,label:g(e,o)});return a.forEach((function(t){return i.on(t,(function(e){var o={originalEvent:e.originalEvent,lngLat:e.lngLat,point:e.point,target:n};r.emit(t,o)}))})),i},e.prototype._createHtmlCluster=function(t,e,o,n){var r=o.html,i=o.anchor,s=o.minZoom,a=o.maxZoom,u=o.zIndex,l=o.preventMapInteractions,p=new mapgl.HtmlMarker(this.map,{coordinates:t,html:r||String(e),anchor:i,minZoom:s,maxZoom:a,preventMapInteractions:l,zIndex:null!=u?u:h});this._bindHtmlMarkerEvents(t,p,n);var c=p.getContent();return{show:function(){c.hidden&&(c.hidden=!1)},hide:function(){c.hidden||(c.hidden=!0)},destroy:function(){p.destroy()},setContent:function(t){p.setContent(t)},setAnchor:function(t){p.setAnchor(t)}}},e.options={radius:80,disableClusteringAtZoom:20,clusterStyle:{icon:s,labelColor:"#000000",labelFontSize:14,labelAnchor:[0,0],labelText:void 0}},e}(i);function v(t,e){return void 0!==t?e:void 0}function g(t,e){var o,n,r,i,s,a;return{text:null!==(o=e.labelText)&&void 0!==o?o:String(t),color:e.labelColor||d.color,fontSize:null!==(n=e.labelFontSize)&&void 0!==n?n:d.fontSize,haloRadius:null!==(r=e.labelHaloRadius)&&void 0!==r?r:d.haloRadius,haloColor:e.labelHaloColor||d.haloColor,letterSpacing:null!==(i=e.labelLetterSpacing)&&void 0!==i?i:d.letterSpacing,anchor:e.labelAnchor,offset:(null!==(s=e.labelOffset)&&void 0!==s?s:null===(a=e.labelAnchor)||void 0===a?void 0:a.map((function(t){return-t})))||d.offset,relativeAnchor:e.labelRelativeAnchor||d.relativeAnchor,image:e.labelImage,zIndex:h+1e-5,minZoom:d.minZoom,maxZoom:d.maxZoom,lineHeight:d.lineHeight}}"undefined"!=typeof window&&("mapgl"in window?mapgl.Clusterer=m:(window.__mapglPlugins||(window.__mapglPlugins={}),window.__mapglPlugins.Clusterer=m))}])}));
{
"name": "@2gis/mapgl-clusterer",
"version": "2.4.1",
"version": "2.4.2",
"description": "Marker clustering plugin for Mapgl",

@@ -5,0 +5,0 @@ "main": "dist/clustering.js",

# mapgl-clusterer
Marker clustering plugin for [Mapgl](https://mapgl-docs.2gis.com/)
### Релиз
1. Поставить тэг в [release-maester](http://webmaps.gitlab-pages.2gis.io/release-maester/index.html#/notes?project=jakarta-clustering)
2. Запустить пайплайн на созданом тэге