@mappedin/marker-cluster 6.0.1-beta.48 → 6.0.1-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/index.js +1 -1
- package/package.json +2 -2
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var nt=Object.defineProperty,mt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var st=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var it=n=>{throw TypeError(n)};var W=(n,t,e)=>t in n?nt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,y=(n,t)=>{for(var e in t||(t={}))gt.call(t,e)&&W(n,e,t[e]);if(st)for(var e of st(t))Et.call(t,e)&&W(n,e,t[e]);return n},P=(n,t)=>mt(n,pt(t)),i=(n,t)=>nt(n,"name",{value:t,configurable:!0});var c=(n,t,e)=>W(n,typeof t!="symbol"?t+"":t,e),ot=(n,t,e)=>t.has(n)||it("Cannot "+e);var r=(n,t,e)=>(ot(n,t,"read from private field"),e?e.call(n):t.get(n)),a=(n,t,e)=>t.has(n)?it("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),m=(n,t,e,s)=>(ot(n,t,"write to private field"),s?s.call(n,e):t.set(n,e),e);var h={env:{NODE_ENV:"production",npm_package_version:"6.0.1-beta.
|
|
1
|
+
var nt=Object.defineProperty,mt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var st=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var it=n=>{throw TypeError(n)};var W=(n,t,e)=>t in n?nt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,y=(n,t)=>{for(var e in t||(t={}))gt.call(t,e)&&W(n,e,t[e]);if(st)for(var e of st(t))Et.call(t,e)&&W(n,e,t[e]);return n},P=(n,t)=>mt(n,pt(t)),i=(n,t)=>nt(n,"name",{value:t,configurable:!0});var c=(n,t,e)=>W(n,typeof t!="symbol"?t+"":t,e),ot=(n,t,e)=>t.has(n)||it("Cannot "+e);var r=(n,t,e)=>(ot(n,t,"read from private field"),e?e.call(n):t.get(n)),a=(n,t,e)=>t.has(n)?it("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),m=(n,t,e,s)=>(ot(n,t,"write to private field"),s?s.call(n,e):t.set(n,e),e);var h={env:{NODE_ENV:"production",npm_package_version:"6.0.1-beta.50"}};var yt="[MappedinJS]";function bt(n=""){let t="".concat(yt).concat(n?"-".concat(n):"");return{logState:h.env.NODE_ENV==="test"?3:0,log(...e){this.logState<=0&&console.log(t,...e)},warn(...e){this.logState<=1&&console.warn(t,...e)},error(...e){this.logState<=2&&console.error(t,...e)},assert(...e){console.assert(...e)},time(e){console.time(e)},timeEnd(e){console.timeEnd(e)},setLevel(e){0<=e&&e<=3&&(this.logState=e)}}}i(bt,"createLogger");var xt=bt();var v=xt;var H=class H extends Error{};i(H,"InvalidTokenError");var X=H;X.prototype.name="InvalidTokenError";function at(n,t,e=!1){let s=null,o=0;return function(...l){o++,o===1&&e===!0&&n(...l);let f=i(()=>{(!e||o>1)&&n(...l),s=null,o=0},"later");clearTimeout(s),s=setTimeout(f,t)}}i(at,"debounce");var Z=[0,4,6,8,10],Q=i(()=>{let n=new Array(16).fill(0),t=Math.random()*4294967296;for(let s=0;s<n.length;s++)s>0&&(s&3)===0&&(t=Math.random()*4294967296),n[s]=t>>>((s&3)<<3)&255;let e=n.map(s=>s.toString(16).padStart(2,"0"));return e[6]="4"+e[6][1],e[8]=["8","9","a","b"].includes(e[7][0])?e[7]:"a"+e[7][1],Z.map((s,o)=>e.slice(s,o===Z.length-1?void 0:Z[o+1]).join("")).join("-")},"randomId");var V=["red","blue","green","purple","orange","pink","brown","gray","black","magenta","cyan","silver","maroon","teal","aqua"],ut=i((n,t,e)=>'<div style="background-color:'.concat(t,";color:white;width:").concat(e,"px;height:").concat(e,"px;border-radius:50%;text-align:center;line-height:").concat(e,"px;border:1px solid white;font-size:").concat(Math.floor(e*.7),'px;">').concat(n,"</div>"),"debugMarkerFn");import{Coordinate as lt}from"@mappedin/mappedin-js";var B=i(n=>parseFloat(n.toFixed(8)),"trimCoordValue"),ct=i((n,t)=>{if(n.length===0)return new lt({latitude:0,longitude:0});let e=n.reduce((o,l)=>o+l.latitude,0)/n.length,s=n.reduce((o,l)=>o+l.longitude,0)/n.length;return new lt({latitude:B(e),longitude:B(s),floorId:t!=null?t:n[0].floorId})},"averageCoords"),dt=i((n,t)=>n.length===0?"":[...n.map(e=>e.id).sort(),B(t.latitude),B(t.longitude),t.floorId].filter(e=>e!=null).join("-"),"getClusterId"),ht=i((n,t)=>{if(t<=0)throw new Error("Buffer must be greater than 0");return{minX:n.x-t/2,minY:n.y-t/2,maxX:n.x+t/2,maxY:n.y+t/2}},"bufferPoint");import It from"rbush";var R=i(n=>"".concat(n.x,",").concat(n.y),"serializePoint"),g,j=class j extends It{constructor(){super(...arguments);a(this,g,new Map);c(this,"load",i(e=>{for(let s of e)r(this,g).set(R(s),s);return super.load(e)},"load"));c(this,"insert",i(e=>(r(this,g).set(R(e),e),super.insert(e)),"insert"));c(this,"remove",i(e=>(r(this,g).delete(R(e)),super.remove(e)),"remove"));c(this,"clear",i(()=>(r(this,g).clear(),super.clear()),"clear"));c(this,"peek",i(()=>r(this,g).values().next().value,"peek"));c(this,"has",i(e=>r(this,g).has(R(e)),"has"));c(this,"find",i(e=>{for(let s of r(this,g).values())if(e(s))return s},"find"));c(this,"toBBox",i(e=>({minX:e.x,minY:e.y,maxX:e.x,maxY:e.y}),"toBBox"));c(this,"compareMinX",i((e,s)=>e.x-s.x,"compareMinX"));c(this,"compareMinY",i((e,s)=>e.y-s.y,"compareMinY"));c(this,"equals",i((e,s)=>e.x===s.x&&e.y===s.y,"equals"))}get size(){return r(this,g).size}};g=new WeakMap,i(j,"PointRBush");var w=j;var D,b,E,M,x,$,Y,tt=class tt{constructor(t){a(this,D);a(this,b,{threshold:100});a(this,E,new w);a(this,M,new Map);a(this,x,[]);a(this,$,i(()=>[...r(this,M).values()].map(t=>P(y({},r(this,D).getScreenCoordinateFromCoordinate(t.target.anchorTarget)),{markerId:t.id})),"#getScreenCoordinates"));a(this,Y,i(t=>{let e=[t];r(this,E).remove(t);let s=r(this,E).search(ht(t,r(this,b).threshold));if(s.length===0)return e;e.push(...s);for(let o of s)r(this,E).remove(o);return e},"#resolveNeighbours"));m(this,D,t)}setOptions(t){if(t.threshold!=null&&t.threshold<=0)throw new Error("Cluster threshold must be greater than 0");m(this,b,y(y({},r(this,b)),t))}load(t){r(this,M).clear();for(let e of t)r(this,M).set(e.id,e)}getClusters(){var l;let t=r(this,$).call(this);r(this,E).clear(),r(this,E).load(t);let e=r(this,E),s=[],o=[];for(;e.size>0;){let f=(l=e.find(C=>r(this,x).includes(C)))!=null?l:e.peek();if(f==null)break;o.push(f);let ft=r(this,Y).call(this,f).map(C=>r(this,M).get(C.markerId)).filter(C=>C!=null);s.push(ft)}return m(this,x,o),s}destroy(){r(this,M).clear(),r(this,E).clear(),m(this,x,[])}};D=new WeakMap,b=new WeakMap,E=new WeakMap,M=new WeakMap,x=new WeakMap,$=new WeakMap,Y=new WeakMap,i(tt,"ScreenDistanceClustering");var N=tt;var I,p,d,u,S,_,F,K,G,J,U,q,L,T,k,O,A,rt=class rt{constructor(t,e,s){c(this,"id",Q());a(this,I);a(this,p);a(this,d);a(this,u,{singleMarkersById:new Map,clustersById:new Map,clusterMarkersByClusterId:new Map,debugMarkersByClusterId:new Map,debugColorsByClusterId:new Map});a(this,S);a(this,_);a(this,F,i(()=>[...r(this,u).singleMarkersById.values()],"#getMarkers"));a(this,K,i(t=>{r(this,p).updateState(t,{enabled:!1})},"#hideMarker"));a(this,G,i(t=>{r(this,p).updateState(t,{enabled:!0})},"#showMarker"));a(this,J,i(()=>{let t=r(this,d).algorithm;return t.load(r(this,F).call(this)),t.getClusters()},"#getClusteredMarkers"));a(this,U,i(t=>{var s;let e=ct(t.map(o=>o.target.anchorTarget),(s=r(this,d).floor)==null?void 0:s.id);return{id:dt(t,e),markers:t,center:e}},"#createCluster"));a(this,q,i(t=>{var o;let e=(o=r(this,u).debugColorsByClusterId.get(t.id))!=null?o:V[0],s=r(this,S).call(this,t);s!=null&&r(this,u).clusterMarkersByClusterId.set(t.id,s);for(let l of t.markers)r(this,d).debug&&(l.contentEl.style.outline="2px solid ".concat(e)),r(this,d).hideClusteredMarkers&&r(this,K).call(this,l);if(r(this,d).debug){(s==null?void 0:s.contentEl.firstChild)instanceof HTMLElement&&(s.contentEl.firstChild.style.opacity="0.25");let l=r(this,p).Markers.add(t.center,ut(t.markers.length.toString(),e,20),{rank:"always-visible",zIndex:99});r(this,u).debugMarkersByClusterId.set(t.id,l)}},"#addClusterMarkers"));a(this,L,i(t=>{let e=r(this,u).clusterMarkersByClusterId.get(t.id);if(e!=null&&(r(this,p).Markers.remove(e),r(this,u).clusterMarkersByClusterId.delete(t.id)),r(this,d).debug){let s=r(this,u).debugMarkersByClusterId.get(t.id);s!=null&&(r(this,p).Markers.remove(s),r(this,u).debugMarkersByClusterId.delete(t.id))}for(let s of t.markers)r(this,G).call(this,s)},"#removeClusterMarkers"));a(this,T,i(()=>{let t=new Map(r(this,u).clustersById),e=[],s=r(this,J).call(this);for(let o=0;o<s.length;o++){let l=s[o];if(l.length<r(this,d).minSize)continue;let f=r(this,U).call(this,l);r(this,u).clustersById.has(f.id)?t.delete(f.id):e.push(f)}for(let o of t.values())r(this,L).call(this,o),r(this,u).clustersById.delete(o.id),r(this,d).debug&&r(this,u).debugColorsByClusterId.delete(o.id);for(let o of e){if(r(this,d).debug){let l=V[Math.floor(Math.random()*V.length)];r(this,u).debugColorsByClusterId.set(o.id,l)}r(this,q).call(this,o),r(this,u).clustersById.set(o.id,o)}},"#updateImmediately"));a(this,k,i(()=>{r(this,d).debounce===0?r(this,T).call(this):r(this,_).call(this)},"#update"));a(this,O,i(()=>{r(this,k).call(this)},"#handleCameraChange"));a(this,A,i(()=>{r(this,T).call(this)},"#handleFocus"));c(this,"add",i(t=>{var e,s;if(r(this,d).floor==null)r(this,d).floor=(s=r(this,I).getById("floor",(e=t.target.anchorTarget.floorId)!=null?e:""))!=null?s:null;else if(r(this,d).floor.id!==t.target.anchorTarget.floorId)throw new Error("Cannot cluster markers on different floors!");r(this,u).singleMarkersById.set(t.id,t),r(this,k).call(this)},"add"));c(this,"remove",i(t=>{if(!r(this,u).singleMarkersById.has(t.id)){v.log("Cannot remove marker ".concat(t.id," because it is not in the cluster!"));return}r(this,u).singleMarkersById.delete(t.id),r(this,k).call(this)},"remove"));c(this,"has",i(t=>r(this,u).singleMarkersById.has(t.id),"has"));c(this,"destroy",i(()=>{r(this,d).algorithm.destroy(),r(this,p).off("camera-change",r(this,O)),window.removeEventListener("focus",r(this,A));for(let[,t]of r(this,u).clustersById)r(this,L).call(this,t);for(let t of Object.values(r(this,u)))if(t instanceof Map)t.clear();else throw new Error("Encountered unexpected data type in cache! Potentially failed to clean up MarkerCluster.")},"destroy"));var l,f;let o;if((s==null?void 0:s.algorithm)==null){let z=new N(t);z.setOptions((l=s==null?void 0:s.algorithmOptions)!=null?l:{}),o=z}else o=s.algorithm,o.setOptions((f=s==null?void 0:s.algorithmOptions)!=null?f:{});if(m(this,d,P(y({floor:null,minSize:2,debounce:50,debug:!1,hideClusteredMarkers:!0},s),{algorithm:o})),m(this,p,t),m(this,I,Object.values(r(this,p).getMapData())[0]),r(this,I)==null)throw new Error("No map data found in MapView!");m(this,S,e),m(this,_,at(r(this,T),r(this,d).debounce)),r(this,p).on("camera-change",r(this,O)),window.addEventListener("focus",r(this,A))}get clusters(){return[...r(this,u).clustersById.values()]}};I=new WeakMap,p=new WeakMap,d=new WeakMap,u=new WeakMap,S=new WeakMap,_=new WeakMap,F=new WeakMap,K=new WeakMap,G=new WeakMap,J=new WeakMap,U=new WeakMap,q=new WeakMap,L=new WeakMap,T=new WeakMap,k=new WeakMap,O=new WeakMap,A=new WeakMap,i(rt,"MarkerCluster");var et=rt;export{et as MarkerCluster,w as PointRBush,N as ScreenDistanceClustering};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/marker-cluster",
|
|
3
|
-
"version": "6.0.1-beta.
|
|
3
|
+
"version": "6.0.1-beta.50",
|
|
4
4
|
"homepage": "https://developer.mappedin.com/",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/esm/index.js",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"volta": {
|
|
31
31
|
"extends": "../../package.json"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "2a421dbb5f163bf7bbcef2937c806909b21818f3"
|
|
34
34
|
}
|