cmap-core 0.0.7 → 0.0.9
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/dist/cmap-core.css +1 -1
- package/dist/index.es.d.ts +217 -28
- package/dist/index.es.js +1949 -1279
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9 -9
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -3
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("mapbox-gl")):typeof define=="function"&&define.amd?define(["exports","mapbox-gl"],I):(C=typeof globalThis<"u"?globalThis:C||self,I(C["cmap-core"]={},C.mapboxgl))})(this,(function(C,I){"use strict";function Ne(e){return["boolean","number"].includes(typeof e)?!1:e instanceof Array?e.length===0:e instanceof Object?JSON.stringify(e)==="{}":["null",null,void 0,"undefined",""].includes(e)}class Vt{_options;cacheKey;cacheType;constructor(t){this._options=t,this.cacheKey=t.uniqueKey+"-",this.cacheType=t.type}set({name:t,content:n}){const i=`${this.cacheKey}${t}`;typeof n=="function"&&(n=n.toString());const s={dataType:typeof n,content:n,type:this.cacheType,datetime:new Date().getTime()};this.cacheType==="sessionstorage"?window.sessionStorage.setItem(i,JSON.stringify(s)):window.localStorage.setItem(i,JSON.stringify(s))}get(t){const n=`${this.cacheKey}${t}`;let i="";if(this.cacheType==="sessionstorage"?i=window.sessionStorage.getItem(n):i=window.localStorage.getItem(n),Ne(i)){console.warn(`未找到缓存,${t}不存在!`);return}try{const s=JSON.parse(i);return["string","number","boolean","object"].includes(s.dataType)?s.content:s.dataType==="function"?this.stringParseToFunction(s.content):s.content}catch{return i}}remove(t){const n=`${this.cacheKey}${t}`;this.cacheType==="sessionstorage"?window.sessionStorage.removeItem(n):window.localStorage.removeItem(n)}removeAll(){const t=[];if(this.cacheType==="sessionstorage")for(let n=0;n<=window.sessionStorage.length;n++)t.push({name:window.sessionStorage.key(n),content:this.get(window.sessionStorage.key(n))});else for(let n=0;n<=window.localStorage.length;n++)t.push({name:window.localStorage.key(n),content:this.get(window.localStorage.key(n))});return t}stringParseToFunction(t){return new Function('"use strict"; return ('+t+")")()}}function Qt(e,t,n=0,i=e.length-1,s=Fe){for(;i>n;){if(i-n>600){const c=i-n+1,h=t-n+1,l=Math.log(c),u=.5*Math.exp(2*l/3),g=.5*Math.sqrt(l*u*(c-u)/c)*(h-c/2<0?-1:1),x=Math.max(n,Math.floor(t-h*u/c+g)),w=Math.min(i,Math.floor(t+(c-h)*u/c+g));Qt(e,t,x,w,s)}const r=e[t];let a=n,o=i;for(rt(e,n,t),s(e[i],r)>0&&rt(e,n,i);a<o;){for(rt(e,a,o),a++,o--;s(e[a],r)<0;)a++;for(;s(e[o],r)>0;)o--}s(e[n],r)===0?rt(e,n,o):(o++,rt(e,o,i)),o<=t&&(n=o+1),t<=o&&(i=o-1)}}function rt(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function Fe(e,t){return e<t?-1:e>t?1:0}class Ye{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const i=[];if(!xt(t,n))return i;const s=this.toBBox,r=[];for(;n;){for(let a=0;a<n.children.length;a++){const o=n.children[a],c=n.leaf?s(o):o;xt(t,c)&&(n.leaf?i.push(o):Ct(t,c)?this._all(o,i):r.push(o))}n=r.pop()}return i}collides(t){let n=this.data;if(!xt(t,n))return!1;const i=[];for(;n;){for(let s=0;s<n.children.length;s++){const r=n.children[s],a=n.leaf?this.toBBox(r):r;if(xt(t,a)){if(n.leaf||Ct(t,a))return!0;i.push(r)}}n=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const i=this.data;this.data=n,n=i}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Q([]),this}remove(t,n){if(!t)return this;let i=this.data;const s=this.toBBox(t),r=[],a=[];let o,c,h;for(;i||r.length;){if(i||(i=r.pop(),c=r[r.length-1],o=a.pop(),h=!0),i.leaf){const l=De(t,i.children,n);if(l!==-1)return i.children.splice(l,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Ct(i,s)?(r.push(i),a.push(o),o=0,c=i,i=i.children[0]):c?(o++,i=c.children[o],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const i=[];for(;t;)t.leaf?n.push(...t.children):i.push(...t.children),t=i.pop();return n}_build(t,n,i,s){const r=i-n+1;let a=this._maxEntries,o;if(r<=a)return o=Q(t.slice(n,i+1)),V(o,this.toBBox),o;s||(s=Math.ceil(Math.log(r)/Math.log(a)),a=Math.ceil(r/Math.pow(a,s-1))),o=Q([]),o.leaf=!1,o.height=s;const c=Math.ceil(r/a),h=c*Math.ceil(Math.sqrt(a));te(t,n,i,h,this.compareMinX);for(let l=n;l<=i;l+=h){const u=Math.min(l+h-1,i);te(t,l,u,c,this.compareMinY);for(let g=l;g<=u;g+=c){const x=Math.min(g+c-1,u);o.children.push(this._build(t,g,x,s-1))}}return V(o,this.toBBox),o}_chooseSubtree(t,n,i,s){for(;s.push(n),!(n.leaf||s.length-1===i);){let r=1/0,a=1/0,o;for(let c=0;c<n.children.length;c++){const h=n.children[c],l=kt(h),u=Re(t,h)-l;u<a?(a=u,r=l<r?l:r,o=h):u===a&&l<r&&(r=l,o=h)}n=o||n.children[0]}return n}_insert(t,n,i){const s=i?t:this.toBBox(t),r=[],a=this._chooseSubtree(s,this.data,n,r);for(a.children.push(t),at(a,s);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(s,r,n)}_split(t,n){const i=t[n],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const a=this._chooseSplitIndex(i,r,s),o=Q(i.children.splice(a,i.children.length-a));o.height=i.height,o.leaf=i.leaf,V(i,this.toBBox),V(o,this.toBBox),n?t[n-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,n){this.data=Q([t,n]),this.data.height=t.height+1,this.data.leaf=!1,V(this.data,this.toBBox)}_chooseSplitIndex(t,n,i){let s,r=1/0,a=1/0;for(let o=n;o<=i-n;o++){const c=ot(t,0,o,this.toBBox),h=ot(t,o,i,this.toBBox),l=Xe(c,h),u=kt(c)+kt(h);l<r?(r=l,s=o,a=u<a?u:a):l===r&&u<a&&(a=u,s=o)}return s||i-n}_chooseSplitAxis(t,n,i){const s=t.leaf?this.compareMinX:Te,r=t.leaf?this.compareMinY:Be,a=this._allDistMargin(t,n,i,s),o=this._allDistMargin(t,n,i,r);a<o&&t.children.sort(s)}_allDistMargin(t,n,i,s){t.children.sort(s);const r=this.toBBox,a=ot(t,0,n,r),o=ot(t,i-n,i,r);let c=vt(a)+vt(o);for(let h=n;h<i-n;h++){const l=t.children[h];at(a,t.leaf?r(l):l),c+=vt(a)}for(let h=i-n-1;h>=n;h--){const l=t.children[h];at(o,t.leaf?r(l):l),c+=vt(o)}return c}_adjustParentBBoxes(t,n,i){for(let s=i;s>=0;s--)at(n[s],t)}_condense(t){for(let n=t.length-1,i;n>=0;n--)t[n].children.length===0?n>0?(i=t[n-1].children,i.splice(i.indexOf(t[n]),1)):this.clear():V(t[n],this.toBBox)}}function De(e,t,n){if(!n)return t.indexOf(e);for(let i=0;i<t.length;i++)if(n(e,t[i]))return i;return-1}function V(e,t){ot(e,0,e.children.length,t,e)}function ot(e,t,n,i,s){s||(s=Q(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<n;r++){const a=e.children[r];at(s,e.leaf?i(a):a)}return s}function at(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Te(e,t){return e.minX-t.minX}function Be(e,t){return e.minY-t.minY}function kt(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function vt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Re(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Xe(e,t){const n=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),s=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,s-n)*Math.max(0,r-i)}function Ct(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function xt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Q(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function te(e,t,n,i,s){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=i)continue;const a=t+Math.ceil((n-t)/i/2)*i;Qt(e,a,t,n,s),r.push(t,a,a,n)}}var ht=(e=>(e[e.MIN_X=0]="MIN_X",e[e.MIN_Y=1]="MIN_Y",e[e.MAX_X=2]="MAX_X",e[e.MAX_Y=3]="MAX_Y",e))(ht||{});class ee{static MIN_X=ht.MIN_X;static MIN_Y=ht.MIN_Y;static MAX_X=ht.MAX_X;static MAX_Y=ht.MAX_Y;id;visible=!0;dir="top-left";dirs=["top-left","top-right","bottom-left","bottom-right","center","top","bottom","left","right"];_options;constructor(t){this.id=t.id,this._options=t}get minX(){return this._options[this.dir].minX}get minY(){return this._options[this.dir].minY}get maxX(){return this._options[this.dir].maxX}get maxY(){return this._options[this.dir].maxY}getBBox(){return this._options[this.dir]}setVisible(t){this.visible=t}setDir(t){this.dir=t}isIntersect(t){const{minX:n,minY:i,maxX:s,maxY:r}=t;return n<=this.minX&&i<=this.minY&&this.maxX<=s&&this.maxY<=r}}class ne{_tree=new Ye;_map;_collisionList=[];constructor(t,n){this._map=t,Array.isArray(n?.collisions)&&n.collisions.length>0&&this.load(n.collisions)}load(t){return this._tree.clear(),this._collisionList=t.map(n=>new ee(n)),this.collides()}getItem(t){return this._collisionList.find(n=>n.id===t)}clear(){this._tree.clear()}getCollisions(){return this._collisionList}collides(){for(const t of this._collisionList)for(const n of t.dirs){t.setDir(n);const i=this._tree.collides(t);if(t.setVisible(!i),t.visible){this._tree.insert(t);break}}return this.getCollisions()}}const ze="mapbox-gl-cache";var Nt=(e=>(e[e.SUCCESS=0]="SUCCESS",e[e.FAIL=-1]="FAIL",e))(Nt||{}),Y=63710088e-1,ie={centimeters:Y*100,centimetres:Y*100,degrees:360/(2*Math.PI),feet:Y*3.28084,inches:Y*39.37,kilometers:Y/1e3,kilometres:Y/1e3,meters:Y,metres:Y,miles:Y/1609.344,millimeters:Y*1e3,millimetres:Y*1e3,nauticalmiles:Y/1852,radians:1,yards:Y*1.0936};function ct(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function Ft(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!oe(e[0])||!oe(e[1]))throw new Error("coordinates must contain numbers");return ct({type:"Point",coordinates:e},t,n)}function se(e,t,n={}){for(const s of e){if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(s[s.length-1].length!==s[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<s[s.length-1].length;r++)if(s[s.length-1][r]!==s[0][r])throw new Error("First and last Position are not equivalent.")}return ct({type:"Polygon",coordinates:e},t,n)}function Yt(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return ct({type:"LineString",coordinates:e},t,n)}function Ue(e,t,n={}){return ct({type:"MultiLineString",coordinates:e},t,n)}function je(e,t,n={}){return ct({type:"MultiPolygon",coordinates:e},t,n)}function He(e,t="kilometers"){const n=ie[t];if(!n)throw new Error(t+" units is invalid");return e*n}function qe(e,t="kilometers"){const n=ie[t];if(!n)throw new Error(t+" units is invalid");return e/n}function Ze(e){return e%(2*Math.PI)*180/Math.PI}function lt(e){return e%360*Math.PI/180}function re(e,t="kilometers",n="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return He(qe(e,t),n)}function oe(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function Je(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function j(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ae(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Ge(e){return e.type==="Feature"?e.geometry:e}function We(e,t,n={}){let i;return n.final?i=he(j(t),j(e)):i=he(j(e),j(t)),i>180?-(360-i):i}function he(e,t){const n=lt(e[1]),i=lt(t[1]);let s=lt(t[0]-e[0]);s>Math.PI&&(s-=2*Math.PI),s<-Math.PI&&(s+=2*Math.PI);const r=Math.log(Math.tan(i/2+Math.PI/4)/Math.tan(n/2+Math.PI/4)),a=Math.atan2(s,r);return(Ze(a)+360)%360}function wt(e,t,n){if(e!==null)for(var i,s,r,a,o,c,h,l=0,u=0,g,x=e.type,w=x==="FeatureCollection",$=x==="Feature",y=w?e.features.length:1,O=0;O<y;O++){h=w?e.features[O].geometry:$?e.geometry:e,g=h?h.type==="GeometryCollection":!1,o=g?h.geometries.length:1;for(var T=0;T<o;T++){var M=0,R=0;if(a=g?h.geometries[T]:h,a!==null){c=a.coordinates;var A=a.type;switch(l=n&&(A==="Polygon"||A==="MultiPolygon")?1:0,A){case null:break;case"Point":if(t(c,u,O,M,R)===!1)return!1;u++,M++;break;case"LineString":case"MultiPoint":for(i=0;i<c.length;i++){if(t(c[i],u,O,M,R)===!1)return!1;u++,A==="MultiPoint"&&M++}A==="LineString"&&M++;break;case"Polygon":case"MultiLineString":for(i=0;i<c.length;i++){for(s=0;s<c[i].length-l;s++){if(t(c[i][s],u,O,M,R)===!1)return!1;u++}A==="MultiLineString"&&M++,A==="Polygon"&&R++}A==="Polygon"&&M++;break;case"MultiPolygon":for(i=0;i<c.length;i++){for(R=0,s=0;s<c[i].length;s++){for(r=0;r<c[i][s].length-l;r++){if(t(c[i][s][r],u,O,M,R)===!1)return!1;u++}R++}M++}break;case"GeometryCollection":for(i=0;i<a.geometries.length;i++)if(wt(a.geometries[i],t,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ce(e,t={}){if(e.bbox!=null&&t.recompute!==!0)return e.bbox;const n=[1/0,1/0,-1/0,-1/0];return wt(e,i=>{n[0]>i[0]&&(n[0]=i[0]),n[1]>i[1]&&(n[1]=i[1]),n[2]<i[0]&&(n[2]=i[0]),n[3]<i[1]&&(n[3]=i[1])}),n}function le(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ke(e,t={}){let n=0,i=0,s=0;return wt(e,function(r){n+=r[0],i+=r[1],s++},!0),Ft([n/s,i/s],t.properties)}function ue(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return fe(e);case"FeatureCollection":return Ve(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Dt(e);default:throw new Error("unknown GeoJSON type")}}function fe(e){const t={type:"Feature"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"properties":case"geometry":return;default:t[n]=e[n]}}),t.properties=pe(e.properties),e.geometry==null?t.geometry=null:t.geometry=Dt(e.geometry),t}function pe(e){const t={};return e&&Object.keys(e).forEach(n=>{const i=e[n];typeof i=="object"?i===null?t[n]=null:Array.isArray(i)?t[n]=i.map(s=>s):t[n]=pe(i):t[n]=i}),t}function Ve(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(n=>{switch(n){case"type":case"features":return;default:t[n]=e[n]}}),t.features=e.features.map(n=>fe(n)),t}function Dt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),e.type==="GeometryCollection"?(t.geometries=e.geometries.map(n=>Dt(n)),t):(t.coordinates=de(e.coordinates),t)}function de(e){const t=e;return typeof t[0]!="object"?t.slice():t.map(n=>de(n))}function Qe(e,t,n={}){const i=j(e),s=j(t);s[0]+=s[0]-i[0]>180?-360:i[0]-s[0]>180?360:0;const r=tn(i,s);return re(r,"meters",n.units)}function tn(e,t,n){n=n===void 0?Y:Number(n);const i=n,s=e[1]*Math.PI/180,r=t[1]*Math.PI/180,a=r-s;let o=Math.abs(t[0]-e[0])*Math.PI/180;o>Math.PI&&(o-=2*Math.PI);const c=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),h=Math.abs(c)>1e-11?a/c:Math.cos(s);return Math.sqrt(a*a+h*h*o*o)*i}function en(e,t,n,i={}){const s=t<0;let r=re(Math.abs(t),i.units,"meters");s&&(r=-Math.abs(r));const a=j(e),o=nn(a,r,n);return o[0]+=o[0]-a[0]>180?-360:a[0]-o[0]>180?360:0,Ft(o,i.properties)}function nn(e,t,n,i){i=i===void 0?Y:Number(i);const s=t/i,r=e[0]*Math.PI/180,a=lt(e[1]),o=lt(n),c=s*Math.cos(o);let h=a+c;Math.abs(h)>Math.PI/2&&(h=h>0?Math.PI-h:-Math.PI-h);const l=Math.log(Math.tan(h/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),u=Math.abs(l)>1e-11?c/l:Math.cos(a),g=s*Math.sin(o)/u;return[((r+g)*180/Math.PI+540)%360-180,h*180/Math.PI]}function sn(e,t,n){if(n=n||{},!Je(n))throw new Error("options is invalid");const i=n.pivot,s=n.mutate;if(!e)throw new Error("geojson is required");if(t==null||isNaN(t))throw new Error("angle is required");if(t===0)return e;const r=i??Ke(e);return(s===!1||s===void 0)&&(e=ue(e)),wt(e,function(a){const c=We(r,a)+t,h=Qe(r,a),l=ae(en(r,h,c));a[0]=l[0],a[1]=l[1]}),e}function rn(e,t={}){var n,i,s,r=t.properties,a=(n=t.autoComplete)!=null?n:!0,o=(i=t.orderCoords)!=null?i:!0,c=(s=t.mutate)!=null?s:!1;if(c||(e=ue(e)),e.type==="FeatureCollection"){var h=[];return e.features.forEach(function(l){h.push(ae(me(l,{},a,o)))}),je(h,r)}else return me(e,r,a,o)}function me(e,t,n,i){t=t||(e.type==="Feature"?e.properties:{});var s=Ge(e),r=s.coordinates,a=s.type;if(!r.length)throw new Error("line must contain coordinates");switch(a){case"LineString":return n&&(r=ge(r)),se([r],t);case"MultiLineString":var o=[],c=0;return r.forEach(function(h){if(n&&(h=ge(h)),i){var l=on(ce(Yt(h)));l>c?(o.unshift(h),c=l):o.push(h)}else o.push(h)}),se(o,t);default:throw new Error("geometry type "+a+" is not supported")}}function ge(e){var t=e[0],n=t[0],i=t[1],s=e[e.length-1],r=s[0],a=s[1];return(n!==r||i!==a)&&e.push(t),e}function on(e){var t=e[0],n=e[1],i=e[2],s=e[3];return Math.abs(t-i)*Math.abs(n-s)}function ut(e,t,n){const s=e.getCenter().lat,r=e.getZoom(),a=s*(Math.PI/180),o=40075017*Math.cos(a)/Math.pow(2,r+9);return t/o}async function an(e,t,n){const s=await(u=>new Promise((g,x)=>{const w=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),$=URL.createObjectURL(w),y=new Image;y.crossOrigin="anonymous",y.onload=()=>{URL.revokeObjectURL($),g(y)},y.onerror=O=>{URL.revokeObjectURL($),x(new Error(`SVG图片加载失败:${JSON.stringify(O)}`))},y.src=$}))(e),r=s.naturalWidth||s.width||300,a=s.naturalHeight||s.height||150,o=document.createElement("canvas");o.width=r,o.height=a;const c=o.getContext("2d");if(!c)throw new Error("无法获取Canvas 2D上下文");c.clearRect(0,0,r,a),c.drawImage(s,0,0,r,a);const[h,l]=await Promise.all([createImageBitmap(o),Promise.resolve(c.getImageData(0,0,r,a))]);return{image:s,bitmap:h,imageData:l}}class tt{static SUCCESS=Nt.SUCCESS;static FAIL=Nt.FAIL;_map;_cache=new Vt({uniqueKey:`${ze}-icon`,type:"localstorage"});constructor(t){this._map=t}async load(t){const n=await Promise.allSettled(t.map(r=>this.add(r))),i=[],s=[];return n.forEach(r=>{r.status==="fulfilled"?i.push(r.value):s.push(r.reason)}),{success:i,error:s}}async addSvg(t){if(this.has(t.name))console.log("有了");else{const n=await an(t.svg);this._cache.set({name:t.name,content:{width:n.image.width,height:n.image.height,image:n.image}}),this._map.addImage(t.name,n.image)}}add(t){return new Promise((n,i)=>{this.has(t.name)?i(this.error(t,"The image has been loaded!")):this._map.loadImage(t.url,(s,r)=>{if(s){i(this.error(t,s));return}if(r)this._cache.set({name:t.name,content:{width:r.width,height:r.height,image:r}}),this._map.addImage(t.name,r,t.options),n(this.success(t));else{i(this.error(t,"The image has not found!"));return}})})}has(t){return this._map.hasImage(t)}getImage(t){return this._cache.get(t)}update(t){return new Promise((n,i)=>{if(!this._map.hasImage(t.name)){i(this.error(t,"The image has not been loaded!"));return}this._map.loadImage(t.url,(s,r)=>{if(s){i(this.error(t,s));return}if(r)this._cache.set({name:t.name,content:{width:r.width,height:r.height}}),this._map.updateImage(t.name,r),n(this.success(t));else{i(this.error(t,"The image has not found!"));return}})})}delete(t){this._map.hasImage(t)&&(this._map.removeImage(t),this._cache.remove(t))}success(t){return{code:tt.SUCCESS,data:t,msg:`The ${t.name} was successfully added`}}error(t,n){return{code:tt.FAIL,data:t,msg:n}}}var Tt={exports:{}},ye;function hn(){return ye||(ye=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1));function s(c,h,l){this.fn=c,this.context=h,this.once=l||!1}function r(c,h,l,u,g){if(typeof l!="function")throw new TypeError("The listener must be a function");var x=new s(l,u||c,g),w=n?n+h:h;return c._events[w]?c._events[w].fn?c._events[w]=[c._events[w],x]:c._events[w].push(x):(c._events[w]=x,c._eventsCount++),c}function a(c,h){--c._eventsCount===0?c._events=new i:delete c._events[h]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var h=[],l,u;if(this._eventsCount===0)return h;for(u in l=this._events)t.call(l,u)&&h.push(n?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(l)):h},o.prototype.listeners=function(h){var l=n?n+h:h,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var g=0,x=u.length,w=new Array(x);g<x;g++)w[g]=u[g].fn;return w},o.prototype.listenerCount=function(h){var l=n?n+h:h,u=this._events[l];return u?u.fn?1:u.length:0},o.prototype.emit=function(h,l,u,g,x,w){var $=n?n+h:h;if(!this._events[$])return!1;var y=this._events[$],O=arguments.length,T,M;if(y.fn){switch(y.once&&this.removeListener(h,y.fn,void 0,!0),O){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,l),!0;case 3:return y.fn.call(y.context,l,u),!0;case 4:return y.fn.call(y.context,l,u,g),!0;case 5:return y.fn.call(y.context,l,u,g,x),!0;case 6:return y.fn.call(y.context,l,u,g,x,w),!0}for(M=1,T=new Array(O-1);M<O;M++)T[M-1]=arguments[M];y.fn.apply(y.context,T)}else{var R=y.length,A;for(M=0;M<R;M++)switch(y[M].once&&this.removeListener(h,y[M].fn,void 0,!0),O){case 1:y[M].fn.call(y[M].context);break;case 2:y[M].fn.call(y[M].context,l);break;case 3:y[M].fn.call(y[M].context,l,u);break;case 4:y[M].fn.call(y[M].context,l,u,g);break;default:if(!T)for(A=1,T=new Array(O-1);A<O;A++)T[A-1]=arguments[A];y[M].fn.apply(y[M].context,T)}}return!0},o.prototype.on=function(h,l,u){return r(this,h,l,u,!1)},o.prototype.once=function(h,l,u){return r(this,h,l,u,!0)},o.prototype.removeListener=function(h,l,u,g){var x=n?n+h:h;if(!this._events[x])return this;if(!l)return a(this,x),this;var w=this._events[x];if(w.fn)w.fn===l&&(!g||w.once)&&(!u||w.context===u)&&a(this,x);else{for(var $=0,y=[],O=w.length;$<O;$++)(w[$].fn!==l||g&&!w[$].once||u&&w[$].context!==u)&&y.push(w[$]);y.length?this._events[x]=y.length===1?y[0]:y:a(this,x)}return this},o.prototype.removeAllListeners=function(h){var l;return h?(l=n?n+h:h,this._events[l]&&a(this,l)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,e.exports=o})(Tt)),Tt.exports}var cn=hn();const Bt=le(cn);var ln=typeof global=="object"&&global&&global.Object===Object&&global,un=typeof self=="object"&&self&&self.Object===Object&&self,Rt=ln||un||Function("return this")(),et=Rt.Symbol,ve=Object.prototype,fn=ve.hasOwnProperty,pn=ve.toString,ft=et?et.toStringTag:void 0;function dn(e){var t=fn.call(e,ft),n=e[ft];try{e[ft]=void 0;var i=!0}catch{}var s=pn.call(e);return i&&(t?e[ft]=n:delete e[ft]),s}var mn=Object.prototype,gn=mn.toString;function yn(e){return gn.call(e)}var vn="[object Null]",xn="[object Undefined]",xe=et?et.toStringTag:void 0;function we(e){return e==null?e===void 0?xn:vn:xe&&xe in Object(e)?dn(e):yn(e)}function wn(e){return e!=null&&typeof e=="object"}var _n="[object Symbol]";function Xt(e){return typeof e=="symbol"||wn(e)&&we(e)==_n}function bn(e,t){for(var n=-1,i=e==null?0:e.length,s=Array(i);++n<i;)s[n]=t(e[n],n,e);return s}var zt=Array.isArray,_e=et?et.prototype:void 0,be=_e?_e.toString:void 0;function Me(e){if(typeof e=="string")return e;if(zt(e))return bn(e,Me)+"";if(Xt(e))return be?be.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _t(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Mn="[object AsyncFunction]",Sn="[object Function]",En="[object GeneratorFunction]",Ln="[object Proxy]";function In(e){if(!_t(e))return!1;var t=we(e);return t==Sn||t==En||t==Mn||t==Ln}var Ut=Rt["__core-js_shared__"],Se=(function(){var e=/[^.]+$/.exec(Ut&&Ut.keys&&Ut.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function $n(e){return!!Se&&Se in e}var On=Function.prototype,An=On.toString;function Pn(e){if(e!=null){try{return An.call(e)}catch{}try{return e+""}catch{}}return""}var kn=/[\\^$.*+?()[\]{}|]/g,Cn=/^\[object .+?Constructor\]$/,Nn=Function.prototype,Fn=Object.prototype,Yn=Nn.toString,Dn=Fn.hasOwnProperty,Tn=RegExp("^"+Yn.call(Dn).replace(kn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Bn(e){if(!_t(e)||$n(e))return!1;var t=In(e)?Tn:Cn;return t.test(Pn(e))}function Rn(e,t){return e?.[t]}function jt(e,t){var n=Rn(e,t);return Bn(n)?n:void 0}var Ee=(function(){try{var e=jt(Object,"defineProperty");return e({},"",{}),e}catch{}})(),Xn=9007199254740991,zn=/^(?:0|[1-9]\d*)$/;function Un(e,t){var n=typeof e;return t=t??Xn,!!t&&(n=="number"||n!="symbol"&&zn.test(e))&&e>-1&&e%1==0&&e<t}function jn(e,t,n){t=="__proto__"&&Ee?Ee(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Le(e,t){return e===t||e!==e&&t!==t}var Hn=Object.prototype,qn=Hn.hasOwnProperty;function Zn(e,t,n){var i=e[t];(!(qn.call(e,t)&&Le(i,n))||n===void 0&&!(t in e))&&jn(e,t,n)}var Jn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Gn=/^\w*$/;function Wn(e,t){if(zt(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Xt(e)?!0:Gn.test(e)||!Jn.test(e)||t!=null&&e in Object(t)}var pt=jt(Object,"create");function Kn(){this.__data__=pt?pt(null):{},this.size=0}function Vn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Qn="__lodash_hash_undefined__",ti=Object.prototype,ei=ti.hasOwnProperty;function ni(e){var t=this.__data__;if(pt){var n=t[e];return n===Qn?void 0:n}return ei.call(t,e)?t[e]:void 0}var ii=Object.prototype,si=ii.hasOwnProperty;function ri(e){var t=this.__data__;return pt?t[e]!==void 0:si.call(t,e)}var oi="__lodash_hash_undefined__";function ai(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=pt&&t===void 0?oi:t,this}function H(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}H.prototype.clear=Kn,H.prototype.delete=Vn,H.prototype.get=ni,H.prototype.has=ri,H.prototype.set=ai;function hi(){this.__data__=[],this.size=0}function bt(e,t){for(var n=e.length;n--;)if(Le(e[n][0],t))return n;return-1}var ci=Array.prototype,li=ci.splice;function ui(e){var t=this.__data__,n=bt(t,e);if(n<0)return!1;var i=t.length-1;return n==i?t.pop():li.call(t,n,1),--this.size,!0}function fi(e){var t=this.__data__,n=bt(t,e);return n<0?void 0:t[n][1]}function pi(e){return bt(this.__data__,e)>-1}function di(e,t){var n=this.__data__,i=bt(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}function nt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}nt.prototype.clear=hi,nt.prototype.delete=ui,nt.prototype.get=fi,nt.prototype.has=pi,nt.prototype.set=di;var mi=jt(Rt,"Map");function gi(){this.size=0,this.__data__={hash:new H,map:new(mi||nt),string:new H}}function yi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Mt(e,t){var n=e.__data__;return yi(t)?n[typeof t=="string"?"string":"hash"]:n.map}function vi(e){var t=Mt(this,e).delete(e);return this.size-=t?1:0,t}function xi(e){return Mt(this,e).get(e)}function wi(e){return Mt(this,e).has(e)}function _i(e,t){var n=Mt(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}function q(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}q.prototype.clear=gi,q.prototype.delete=vi,q.prototype.get=xi,q.prototype.has=wi,q.prototype.set=_i;var bi="Expected a function";function Ht(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(bi);var n=function(){var i=arguments,s=t?t.apply(this,i):i[0],r=n.cache;if(r.has(s))return r.get(s);var a=e.apply(this,i);return n.cache=r.set(s,a)||r,a};return n.cache=new(Ht.Cache||q),n}Ht.Cache=q;var Mi=500;function Si(e){var t=Ht(e,function(i){return n.size===Mi&&n.clear(),i}),n=t.cache;return t}var Ei=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Li=/\\(\\)?/g,Ii=Si(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Ei,function(n,i,s,r){t.push(s?r.replace(Li,"$1"):i||n)}),t});function $i(e){return e==null?"":Me(e)}function Oi(e,t){return zt(e)?e:Wn(e,t)?[e]:Ii($i(e))}function Ai(e){if(typeof e=="string"||Xt(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Pi(e,t,n,i){if(!_t(e))return e;t=Oi(t,e);for(var s=-1,r=t.length,a=r-1,o=e;o!=null&&++s<r;){var c=Ai(t[s]),h=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(s!=a){var l=o[c];h=void 0,h===void 0&&(h=_t(l)?l:Un(t[s+1])?[]:{})}Zn(o,c,h),o=o[c]}return e}function ki(e,t,n){return e==null?e:Pi(e,t,n)}const N=[];for(let e=0;e<256;++e)N.push((e+256).toString(16).slice(1));function Ci(e,t=0){return(N[e[t+0]]+N[e[t+1]]+N[e[t+2]]+N[e[t+3]]+"-"+N[e[t+4]]+N[e[t+5]]+"-"+N[e[t+6]]+N[e[t+7]]+"-"+N[e[t+8]]+N[e[t+9]]+"-"+N[e[t+10]]+N[e[t+11]]+N[e[t+12]]+N[e[t+13]]+N[e[t+14]]+N[e[t+15]]).toLowerCase()}let qt;const Ni=new Uint8Array(16);function Fi(){if(!qt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");qt=crypto.getRandomValues.bind(crypto)}return qt(Ni)}const Ie={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $e(e,t,n){if(Ie.randomUUID&&!e)return Ie.randomUUID();e=e||{};const i=e.random??e.rng?.()??Fi();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Ci(i)}const Zt="mapbox-gl-focus-source",Yi={id:"mapbox-gl-focus-layer",type:"line",source:Zt,paint:{"line-color":"#f00","line-width":3},layout:{}};class Di extends Bt{map;focusItems=[];zoomendFunc=this._zoomend.bind(this);constructor(t){super(),this.map=t,this.onAdd()}get features(){return this.focusItems.map(t=>t.border)}onAdd(){this.map.addSource(Zt,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),this.map.addLayer(Yi)}onRemove(){this.removeAll()}set(t,n){const i=t.id??$e();return this._onHandle(i,t,n),i}get(t){return this.focusItems.find(n=>n.id===t)}remove(t){const n=this.focusItems.findIndex(i=>i.id===t);n!==-1&&this.focusItems.splice(n,1),this.render()}removeAll(){this.focusItems=[],this.render()}render(){const t=this.map.getSource(Zt);t&&(this.features.length>0?t.updateData({type:"FeatureCollection",features:this.features}):t.setData({type:"FeatureCollection",features:this.features}))}_zoomend(){this.render()}_onHandle(t,n,i){const s=this.getFocusBorder(n,i),r={id:t,border:s,feature:n,options:i},a=this.focusItems.findIndex(o=>o.id===t);a!==-1?ki(this.focusItems,a,r):this.focusItems.push(r),this.render(),this.features.length>0?this.map.on("zoomend",this.zoomendFunc):this.map.off("zoomend",this.zoomendFunc)}getFocusBorder(t,n={}){const i=String(t.id??$e()),{padding:s=10,armLength:r=20,size:a=40}=n,o=ce(t),c=1/ut(this.map,1);let h=o,l=0;if(t.geometry.type==="Point"){const g=a/2*c;l=a*.3*c,h=this._expandBBox(o,g,o[1])}else{const u=s*c;l=r*c,h=this._expandBBox(o,u,o[1])}return this._createBracketGeometry(i,h,l)}_expandBBox(t,n,i){const[s,r,a,o]=t,h=n/111319,l=h/Math.cos(i*Math.PI/180);return[s-l,r-h,a+l,o+h]}_createBracketGeometry(t,n,i){const[s,r,a,o]=n,h=i/111319,l=r*Math.PI/180,u=h/Math.cos(l),g=Math.min(h,(o-r)/2),x=Math.min(u,(a-s)/2),w=[[[s+x,r],[s,r],[s,r+g]],[[s,o-g],[s,o],[s+x,o]],[[a-x,o],[a,o],[a,o-g]],[[a,r+g],[a,r],[a-x,r]]];return Ue(w,{id:t},{id:t})}}class Ti{map;constructor(t){this.map=t}addSource(t,n){this.map.getSource(t)||this.map.addSource(t,n)}addLayer(t,n){this.map.getLayer(t.id)||this.map.addLayer(t,n)}getSource(t){return this.map.getSource(t)}updateGeoJSONData(t,n){const i=this.getSource(t);i?.type==="geojson"&&i.updateData(n)}}class Oe{map;events;register;iconManage;focus;constructor(t){this.map=t.map,this.events=new Bt,this.register=new Ti(this.map),this.iconManage=new tt(this.map),this.focus=new Di(this.map)}destroy(){this.events.removeAllListeners()}}const Jt=new WeakMap;function Bi(e){const t=Jt.get(e);if(t)return t;const n=new Oe({map:e});return Jt.set(e,n),e.once("remove",()=>{n.destroy(),Jt.delete(e)}),n}class dt{context;constructor(t){this.context=Bi(t),this.onAdd(),this.context.map.once("beforeRemove",n=>{console.log(n.cancel,"beforeRemove")})}emit(){this.context.events.emit("")}destroy(){this.onRemove()}}const Ri="mapbox-gl-tooltip-connect-line",St="mapbox-gl-tooltip-source",Xi={id:Ri,source:St,type:"line",paint:{"line-color":"#000","line-width":1}};class Ae extends dt{options;visible=!1;mark=null;zoomFunc=this._zoom.bind(this);zoomEndFunc=this._zoom.bind(this);constructor(t,n){super(t),this.options=n,this.visible=!!n.visible,this._create()}get id(){return this.options.id}onAdd(){this.context.register.addSource(St,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),this.context.register.addLayer(Xi)}onRemove(){this.mark&&(this.mark.remove(),this.mark=null)}hide(){this.visible=!1,this.render(),this.context.map.off("zoom",this.zoomFunc),this.context.map.off("zoomend",this.zoomFunc)}show(){this.visible=!0,this.render(),this.context.map.on("zoom",this.zoomFunc),this.context.map.on("zoomend",this.zoomFunc)}setAnchor(t){this.mark&&(this.mark.remove(),this.mark=null),this.context.map.off("zoom",this.zoomFunc),this.context.map.off("zoomend",this.zoomFunc),this.options.anchor=t,this._create(),this.render()}getAllBbox(){return{center:this.getBbox("center"),top:this.getBbox("top"),bottom:this.getBbox("bottom"),left:this.getBbox("left"),right:this.getBbox("right"),"top-left":this.getBbox("top-left"),"top-right":this.getBbox("top-right"),"bottom-left":this.getBbox("bottom-left"),"bottom-right":this.getBbox("bottom-right")}}getBbox(t){if(this.mark===null)return{minX:0,minY:0,maxX:0,maxY:0};const n=t??this.options.anchor,i=this.context.map.project(this.mark.getLngLat()),s=this.mark.getOffset(),{offsetWidth:r,offsetHeight:a}=this.mark.getElement(),o={minX:i.x,minY:i.y,maxX:i.x,maxY:i.y};return n==="top"?(o.minX=i.x-r/2,o.maxX=i.x+r/2,o.maxY=i.y+a+Math.abs(s.y)):n==="bottom"?(o.minX=i.x-r/2,o.maxX=i.x+r/2,o.minY=i.y-a+s.y):n==="left"?(o.maxY=i.y+a/2,o.minY=i.y-a/2,o.maxX=i.x+r+Math.abs(s.x)):n==="right"?(o.maxY=i.y+a/2,o.minY=i.y-a/2,o.minX=i.x-r+s.x):n==="center"?(o.maxY=i.y+a/2,o.minY=i.y-a/2,o.maxX=i.x+r/2,o.minX=i.x-r/2):n==="top-left"?(o.maxY=i.y+a+Math.abs(s.y),o.maxX=i.x+r+Math.abs(s.x)):n==="top-right"?(o.maxY=i.y+a+Math.abs(s.y),o.minX=i.x-r+s.x):n==="bottom-left"?(o.minY=i.y-a+s.y,o.maxX=i.x+r+Math.abs(s.x)):n==="bottom-right"&&(o.minY=i.y-a+s.y,o.minX=i.x-r+s.x),o}remove(){this.mark&&(this.mark.remove(),this.mark=null),this.visible=!1,this.connectLine(),this.context.map.off("zoom",this.zoomFunc),this.context.map.off("zoomend",this.zoomFunc)}_create(){this.mark=new I.Marker({className:this.options.className??"mapbox-gl-tooltip",element:this.options.element,offset:this._getOffsetByAnchor(),anchor:this.options.anchor}).setLngLat(this.options.position),this.visible&&(this.render(),this.context.map.on("zoom",this.zoomFunc),this.context.map.on("zoomend",this.zoomFunc))}_getOffsetByAnchor(){const t=new I.Point(0,0);return this.options.anchor==="center"?(t.x=0,t.y=0):this.options.anchor==="top"?(t.x=0,t.y=this.options.offsetY??0):this.options.anchor==="bottom"?(t.x=0,t.y=-(this.options.offsetY??0)):this.options.anchor==="left"?(t.x=this.options.offsetX??0,t.y=0):this.options.anchor==="right"?(t.x=-(this.options.offsetX??0),t.y=0):this.options.anchor==="top-left"?(t.x=this.options.offsetX??0,t.y=this.options.offsetY??0):this.options.anchor==="top-right"?(t.x=-(this.options.offsetX??0),t.y=this.options.offsetY??0):this.options.anchor==="bottom-left"?(t.x=this.options.offsetX??0,t.y=-(this.options.offsetY??0)):this.options.anchor==="bottom-right"&&(t.x=-(this.options.offsetX??0),t.y=-(this.options.offsetY??0)),t}setLngLat(t){return this.options.position=t,this.mark&&this.mark.setLngLat(t),this}connectLine(){const t=`${String(this.options.id)}-tooltip-connect-line`,n=this.connectPoint();if(!n||!this.visible){const r={type:"Feature",geometry:{type:"Point",coordinates:[0,0]},id:t,properties:{}};this.context.register.updateGeoJSONData(St,r);return}const i=[this.options.position.toArray(),n.toArray()],s=Yt(i,{},{id:t});this.context.register.updateGeoJSONData(St,s)}connectPoint(){if(!this.mark||!this.visible)return null;const t=this.context.map.project(this.mark.getLngLat()),n=this.mark.getOffset();return t.x+=n.x,t.y+=n.y,this.options.anchor==="top-left"?t.x+=this.mark.getElement().offsetWidth/2:this.options.anchor==="top-right"?t.x-=this.mark.getElement().offsetWidth/2:this.options.anchor==="bottom-left"?t.x+=this.mark.getElement().offsetWidth/2:this.options.anchor==="bottom-right"&&(t.x-=this.mark.getElement().offsetWidth/2),this.context.map.unproject(t)}render(){return this.mark?(this.visible?this.mark.addTo(this.context.map):this.mark.remove(),this.connectLine(),this):(console.warn(this,"tooltip尚未初始化"),this)}_zoom(){this.connectLine()}}const X="Ais",mt="mapbox-gl-ship-source",Z="mapbox-gl-ship-icon-layer",J="mapbox-gl-ship-real-layer",zi="mapbox-gl-ship-real-outline-layer";var z=(e=>(e.ONLINE="Online",e.DELAY="Delay",e.OFFLINE="Offline",e))(z||{}),Et=(e=>(e.ONLINE="#03CC02",e.DELAY="#FFFD6C",e.OFFLINE="#999999",e))(Et||{});const Ui=[{id:Z,source:mt,filter:["==","$type","Point"],type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":["get","icon"],"icon-rotate":["get","direction"],"icon-size":["interpolate",["linear"],["zoom"],0,.2,19,.5]}},{id:J,source:mt,type:"fill",layout:{},paint:{"fill-color":["case",["==",["get","updateStatus"],"Online"],"#03CC02",["==",["get","updateStatus"],"Delay"],"#FFFD6C",["==",["get","updateStatus"],"Offline"],"#999999","#999999"]}},{id:zi,source:mt,type:"line",layout:{},paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],"#f00",["boolean",["feature-state","focus"],!1],"#f00","#000"],"line-width":2}}],ji=[{name:`${X}-$color-static`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
1
|
+
(function(M,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("mapbox-gl")):typeof define=="function"&&define.amd?define(["exports","mapbox-gl"],A):(M=typeof globalThis<"u"?globalThis:M||self,A(M["cmap-core"]={},M.mapboxgl))})(this,(function(M,A){"use strict";function Fi(e){return["boolean","number"].includes(typeof e)?!1:e instanceof Array?e.length===0:e instanceof Object?JSON.stringify(e)==="{}":["null",null,void 0,"undefined",""].includes(e)}class be{_options;cacheKey;cacheType;constructor(t){this._options=t,this.cacheKey=t.uniqueKey+"-",this.cacheType=t.type}set({name:t,content:i}){const n=`${this.cacheKey}${t}`;typeof i=="function"&&(i=i.toString());const r={dataType:typeof i,content:i,type:this.cacheType,datetime:new Date().getTime()};this.cacheType==="sessionstorage"?window.sessionStorage.setItem(n,JSON.stringify(r)):window.localStorage.setItem(n,JSON.stringify(r))}get(t){const i=`${this.cacheKey}${t}`;let n="";if(this.cacheType==="sessionstorage"?n=window.sessionStorage.getItem(i):n=window.localStorage.getItem(i),Fi(n)){console.warn(`未找到缓存,${t}不存在!`);return}try{const r=JSON.parse(n);return["string","number","boolean","object"].includes(r.dataType)?r.content:r.dataType==="function"?this.stringParseToFunction(r.content):r.content}catch{return n}}remove(t){const i=`${this.cacheKey}${t}`;this.cacheType==="sessionstorage"?window.sessionStorage.removeItem(i):window.localStorage.removeItem(i)}removeAll(){const t=[];if(this.cacheType==="sessionstorage")for(let i=0;i<=window.sessionStorage.length;i++)t.push({name:window.sessionStorage.key(i),content:this.get(window.sessionStorage.key(i))});else for(let i=0;i<=window.localStorage.length;i++)t.push({name:window.localStorage.key(i),content:this.get(window.localStorage.key(i))});return t}stringParseToFunction(t){return new Function('"use strict"; return ('+t+")")()}}function Se(e,t,i=0,n=e.length-1,r=Bi){for(;n>i;){if(n-i>600){const h=n-i+1,c=t-i+1,l=Math.log(h),u=.5*Math.exp(2*l/3),m=.5*Math.sqrt(l*u*(h-u)/h)*(c-h/2<0?-1:1),y=Math.max(i,Math.floor(t-c*u/h+m)),w=Math.min(n,Math.floor(t+(h-c)*u/h+m));Se(e,t,y,w,r)}const s=e[t];let o=i,a=n;for(xt(e,i,t),r(e[n],s)>0&&xt(e,i,n);o<a;){for(xt(e,o,a),o++,a--;r(e[o],s)<0;)o++;for(;r(e[a],s)>0;)a--}r(e[i],s)===0?xt(e,i,a):(a++,xt(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function xt(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Bi(e,t){return e<t?-1:e>t?1:0}class zi{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let i=this.data;const n=[];if(!$t(t,i))return n;const r=this.toBBox,s=[];for(;i;){for(let o=0;o<i.children.length;o++){const a=i.children[o],h=i.leaf?r(a):a;$t(t,h)&&(i.leaf?n.push(a):Wt(t,h)?this._all(a,n):s.push(a))}i=s.pop()}return n}collides(t){let i=this.data;if(!$t(t,i))return!1;const n=[];for(;i;){for(let r=0;r<i.children.length;r++){const s=i.children[r],o=i.leaf?this.toBBox(s):s;if($t(t,o)){if(i.leaf||Wt(t,o))return!0;n.push(s)}}i=n.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let n=0;n<t.length;n++)this.insert(t[n]);return this}let i=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=i;else if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){const n=this.data;this.data=i,i=n}this._insert(i,this.data.height-i.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=lt([]),this}remove(t,i){if(!t)return this;let n=this.data;const r=this.toBBox(t),s=[],o=[];let a,h,c;for(;n||s.length;){if(n||(n=s.pop(),h=s[s.length-1],a=o.pop(),c=!0),n.leaf){const l=Yi(t,n.children,i);if(l!==-1)return n.children.splice(l,1),s.push(n),this._condense(s),this}!c&&!n.leaf&&Wt(n,r)?(s.push(n),o.push(a),a=0,h=n,n=n.children[0]):h?(a++,n=h.children[a],c=!1):n=null}return this}toBBox(t){return t}compareMinX(t,i){return t.minX-i.minX}compareMinY(t,i){return t.minY-i.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,i){const n=[];for(;t;)t.leaf?i.push(...t.children):n.push(...t.children),t=n.pop();return i}_build(t,i,n,r){const s=n-i+1;let o=this._maxEntries,a;if(s<=o)return a=lt(t.slice(i,n+1)),ht(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=lt([]),a.leaf=!1,a.height=r;const h=Math.ceil(s/o),c=h*Math.ceil(Math.sqrt(o));Me(t,i,n,c,this.compareMinX);for(let l=i;l<=n;l+=c){const u=Math.min(l+c-1,n);Me(t,l,u,h,this.compareMinY);for(let m=l;m<=u;m+=h){const y=Math.min(m+h-1,u);a.children.push(this._build(t,m,y,r-1))}}return ht(a,this.toBBox),a}_chooseSubtree(t,i,n,r){for(;r.push(i),!(i.leaf||r.length-1===n);){let s=1/0,o=1/0,a;for(let h=0;h<i.children.length;h++){const c=i.children[h],l=Kt(c),u=Ui(t,c)-l;u<o?(o=u,s=l<s?l:s,a=c):u===o&&l<s&&(s=l,a=c)}i=a||i.children[0]}return i}_insert(t,i,n){const r=n?t:this.toBBox(t),s=[],o=this._chooseSubtree(r,this.data,i,s);for(o.children.push(t),_t(o,r);i>=0&&s[i].children.length>this._maxEntries;)this._split(s,i),i--;this._adjustParentBBoxes(r,s,i)}_split(t,i){const n=t[i],r=n.children.length,s=this._minEntries;this._chooseSplitAxis(n,s,r);const o=this._chooseSplitIndex(n,s,r),a=lt(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,ht(n,this.toBBox),ht(a,this.toBBox),i?t[i-1].children.push(a):this._splitRoot(n,a)}_splitRoot(t,i){this.data=lt([t,i]),this.data.height=t.height+1,this.data.leaf=!1,ht(this.data,this.toBBox)}_chooseSplitIndex(t,i,n){let r,s=1/0,o=1/0;for(let a=i;a<=n-i;a++){const h=wt(t,0,a,this.toBBox),c=wt(t,a,n,this.toBBox),l=Hi(h,c),u=Kt(h)+Kt(c);l<s?(s=l,r=a,o=u<o?u:o):l===s&&u<o&&(o=u,r=a)}return r||n-i}_chooseSplitAxis(t,i,n){const r=t.leaf?this.compareMinX:ji,s=t.leaf?this.compareMinY:Xi,o=this._allDistMargin(t,i,n,r),a=this._allDistMargin(t,i,n,s);o<a&&t.children.sort(r)}_allDistMargin(t,i,n,r){t.children.sort(r);const s=this.toBBox,o=wt(t,0,i,s),a=wt(t,n-i,n,s);let h=Nt(o)+Nt(a);for(let c=i;c<n-i;c++){const l=t.children[c];_t(o,t.leaf?s(l):l),h+=Nt(o)}for(let c=n-i-1;c>=i;c--){const l=t.children[c];_t(a,t.leaf?s(l):l),h+=Nt(a)}return h}_adjustParentBBoxes(t,i,n){for(let r=n;r>=0;r--)_t(i[r],t)}_condense(t){for(let i=t.length-1,n;i>=0;i--)t[i].children.length===0?i>0?(n=t[i-1].children,n.splice(n.indexOf(t[i]),1)):this.clear():ht(t[i],this.toBBox)}}function Yi(e,t,i){if(!i)return t.indexOf(e);for(let n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function ht(e,t){wt(e,0,e.children.length,t,e)}function wt(e,t,i,n,r){r||(r=lt(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=t;s<i;s++){const o=e.children[s];_t(r,e.leaf?n(o):o)}return r}function _t(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function ji(e,t){return e.minX-t.minX}function Xi(e,t){return e.minY-t.minY}function Kt(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Nt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Ui(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Hi(e,t){const i=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),s=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function Wt(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function $t(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function lt(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Me(e,t,i,n,r){const s=[t,i];for(;s.length;){if(i=s.pop(),t=s.pop(),i-t<=n)continue;const o=t+Math.ceil((i-t)/n/2)*n;Se(e,o,t,i,r),s.push(t,o,o,i)}}var bt=(e=>(e[e.MIN_X=0]="MIN_X",e[e.MIN_Y=1]="MIN_Y",e[e.MAX_X=2]="MAX_X",e[e.MAX_Y=3]="MAX_Y",e))(bt||{});class Ee{static MIN_X=bt.MIN_X;static MIN_Y=bt.MIN_Y;static MAX_X=bt.MAX_X;static MAX_Y=bt.MAX_Y;id;visible=!0;dir="top-left";dirs=["top-left","top-right","bottom-left","bottom-right"];_options;constructor(t){this.id=t.id,this._options=t}get minX(){return this._options[this.dir].minX}get minY(){return this._options[this.dir].minY}get maxX(){return this._options[this.dir].maxX}get maxY(){return this._options[this.dir].maxY}getBBox(){return this._options[this.dir]}setVisible(t){this.visible=t}setDir(t){this.dir=t}isIntersect(t){const{minX:i,minY:n,maxX:r,maxY:s}=t;return i<=this.minX&&n<=this.minY&&this.maxX<=r&&this.maxY<=s}}class Vt{_tree=new zi;_map;_collisionList=[];constructor(t,i){this._map=t,Array.isArray(i?.collisions)&&i.collisions.length>0&&this.load(i.collisions)}load(t){return this._tree.clear(),this._collisionList=t.map(i=>new Ee(i)),this.collides()}getItem(t){return this._collisionList.find(i=>i.id===t)}clear(){this._tree.clear()}getCollisions(){return this._collisionList}collides(){for(const t of this._collisionList)for(const i of t.dirs){t.setDir(i);const n=this._tree.collides(t);if(t.setVisible(!n),t.visible){this._tree.insert(t);break}}return this.getCollisions()}}const qi="mapbox-gl-cache";var Qt=(e=>(e[e.SUCCESS=0]="SUCCESS",e[e.FAIL=-1]="FAIL",e))(Qt||{}),R=63710088e-1,Le={centimeters:R*100,centimetres:R*100,degrees:360/(2*Math.PI),feet:R*3.28084,inches:R*39.37,kilometers:R/1e3,kilometres:R/1e3,meters:R,metres:R,miles:R/1609.344,millimeters:R*1e3,millimetres:R*1e3,nauticalmiles:R/1852,radians:1,yards:R*1.0936};function St(e,t,i={}){const n={type:"Feature"};return(i.id===0||i.id)&&(n.id=i.id),i.bbox&&(n.bbox=i.bbox),n.properties=t||{},n.geometry=e,n}function Dt(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ie(e[0])||!Ie(e[1]))throw new Error("coordinates must contain numbers");return St({type:"Point",coordinates:e},t,i)}function te(e,t,i={}){for(const r of e){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let s=0;s<r[r.length-1].length;s++)if(r[r.length-1][s]!==r[0][s])throw new Error("First and last Position are not equivalent.")}return St({type:"Polygon",coordinates:e},t,i)}function Pt(e,t,i={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return St({type:"LineString",coordinates:e},t,i)}function Zi(e,t,i={}){return St({type:"MultiLineString",coordinates:e},t,i)}function Gi(e,t,i={}){return St({type:"MultiPolygon",coordinates:e},t,i)}function Ji(e,t="kilometers"){const i=Le[t];if(!i)throw new Error(t+" units is invalid");return e*i}function Ki(e,t="kilometers"){const i=Le[t];if(!i)throw new Error(t+" units is invalid");return e/i}function Ce(e){return e%(2*Math.PI)*180/Math.PI}function X(e){return e%360*Math.PI/180}function Ae(e,t="kilometers",i="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return Ji(Ki(e,t),i)}function Ie(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function Wi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function U(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Te(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Vi(e){return e.type==="Feature"?e.geometry:e}function Mt(e,t,i={}){if(i.final===!0)return Qi(e,t);const n=U(e),r=U(t),s=X(n[0]),o=X(r[0]),a=X(n[1]),h=X(r[1]),c=Math.sin(o-s)*Math.cos(h),l=Math.cos(a)*Math.sin(h)-Math.sin(a)*Math.cos(h)*Math.cos(o-s);return Ce(Math.atan2(c,l))}function Qi(e,t){let i=Mt(t,e);return i=(i+180)%360,i}function tn(e,t,i={}){let n;return i.final?n=Oe(U(t),U(e)):n=Oe(U(e),U(t)),n>180?-(360-n):n}function Oe(e,t){const i=X(e[1]),n=X(t[1]);let r=X(t[0]-e[0]);r>Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI);const s=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),o=Math.atan2(r,s);return(Ce(o)+360)%360}function Rt(e,t,i){if(e!==null)for(var n,r,s,o,a,h,c,l=0,u=0,m,y=e.type,w=y==="FeatureCollection",T=y==="Feature",v=w?e.features.length:1,O=0;O<v;O++){c=w?e.features[O].geometry:T?e.geometry:e,m=c?c.type==="GeometryCollection":!1,a=m?c.geometries.length:1;for(var B=0;B<a;B++){var S=0,Y=0;if(o=m?c.geometries[B]:c,o!==null){h=o.coordinates;var k=o.type;switch(l=i&&(k==="Polygon"||k==="MultiPolygon")?1:0,k){case null:break;case"Point":if(t(h,u,O,S,Y)===!1)return!1;u++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<h.length;n++){if(t(h[n],u,O,S,Y)===!1)return!1;u++,k==="MultiPoint"&&S++}k==="LineString"&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<h.length;n++){for(r=0;r<h[n].length-l;r++){if(t(h[n][r],u,O,S,Y)===!1)return!1;u++}k==="MultiLineString"&&S++,k==="Polygon"&&Y++}k==="Polygon"&&S++;break;case"MultiPolygon":for(n=0;n<h.length;n++){for(Y=0,r=0;r<h[n].length;r++){for(s=0;s<h[n][r].length-l;s++){if(t(h[n][r][s],u,O,S,Y)===!1)return!1;u++}Y++}S++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(Rt(o.geometries[n],t,i)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ke(e,t={}){if(e.bbox!=null&&t.recompute!==!0)return e.bbox;const i=[1/0,1/0,-1/0,-1/0];return Rt(e,n=>{i[0]>n[0]&&(i[0]=n[0]),i[1]>n[1]&&(i[1]=n[1]),i[2]<n[0]&&(i[2]=n[0]),i[3]<n[1]&&(i[3]=n[1])}),i}function en(e,t={}){const i=Number(e[0]),n=Number(e[1]),r=Number(e[2]),s=Number(e[3]);if(e.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");const o=[i,n];return te([[o,[r,n],[r,s],[i,s],o]],t.properties,{bbox:e,id:t.id})}function Ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function nn(e,t={}){let i=0,n=0,r=0;return Rt(e,function(s){i+=s[0],n+=s[1],r++},!0),Dt([i/r,n/r],t.properties)}function $e(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return De(e);case"FeatureCollection":return rn(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return ee(e);default:throw new Error("unknown GeoJSON type")}}function De(e){const t={type:"Feature"};return Object.keys(e).forEach(i=>{switch(i){case"type":case"properties":case"geometry":return;default:t[i]=e[i]}}),t.properties=Pe(e.properties),e.geometry==null?t.geometry=null:t.geometry=ee(e.geometry),t}function Pe(e){const t={};return e&&Object.keys(e).forEach(i=>{const n=e[i];typeof n=="object"?n===null?t[i]=null:Array.isArray(n)?t[i]=n.map(r=>r):t[i]=Pe(n):t[i]=n}),t}function rn(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(i=>{switch(i){case"type":case"features":return;default:t[i]=e[i]}}),t.features=e.features.map(i=>De(i)),t}function ee(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),e.type==="GeometryCollection"?(t.geometries=e.geometries.map(i=>ee(i)),t):(t.coordinates=Re(e.coordinates),t)}function Re(e){const t=e;return typeof t[0]!="object"?t.slice():t.map(i=>Re(i))}function sn(e,t,i={}){const n=U(e),r=U(t);r[0]+=r[0]-n[0]>180?-360:n[0]-r[0]>180?360:0;const s=on(n,r);return Ae(s,"meters",i.units)}function on(e,t,i){i=i===void 0?R:Number(i);const n=i,r=e[1]*Math.PI/180,s=t[1]*Math.PI/180,o=s-r;let a=Math.abs(t[0]-e[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);const h=Math.log(Math.tan(s/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),c=Math.abs(h)>1e-11?o/h:Math.cos(r);return Math.sqrt(o*o+c*c*a*a)*n}function an(e,t,i,n={}){const r=t<0;let s=Ae(Math.abs(t),n.units,"meters");r&&(s=-Math.abs(s));const o=U(e),a=cn(o,s,i);return a[0]+=a[0]-o[0]>180?-360:o[0]-a[0]>180?360:0,Dt(a,n.properties)}function cn(e,t,i,n){n=n===void 0?R:Number(n);const r=t/n,s=e[0]*Math.PI/180,o=X(e[1]),a=X(i),h=r*Math.cos(a);let c=o+h;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);const l=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),u=Math.abs(l)>1e-11?h/l:Math.cos(o),m=r*Math.sin(a)/u;return[((s+m)*180/Math.PI+540)%360-180,c*180/Math.PI]}function hn(e,t,i){if(i=i||{},!Wi(i))throw new Error("options is invalid");const n=i.pivot,r=i.mutate;if(!e)throw new Error("geojson is required");if(t==null||isNaN(t))throw new Error("angle is required");if(t===0)return e;const s=n??nn(e);return(r===!1||r===void 0)&&(e=$e(e)),Rt(e,function(o){const h=tn(s,o)+t,c=sn(s,o),l=Te(an(s,c,h));o[0]=l[0],o[1]=l[1]}),e}function ln(e,t={}){var i,n,r,s=t.properties,o=(i=t.autoComplete)!=null?i:!0,a=(n=t.orderCoords)!=null?n:!0,h=(r=t.mutate)!=null?r:!1;if(h||(e=$e(e)),e.type==="FeatureCollection"){var c=[];return e.features.forEach(function(l){c.push(Te(Fe(l,{},o,a)))}),Gi(c,s)}else return Fe(e,s,o,a)}function Fe(e,t,i,n){t=t||(e.type==="Feature"?e.properties:{});var r=Vi(e),s=r.coordinates,o=r.type;if(!s.length)throw new Error("line must contain coordinates");switch(o){case"LineString":return i&&(s=Be(s)),te([s],t);case"MultiLineString":var a=[],h=0;return s.forEach(function(c){if(i&&(c=Be(c)),n){var l=un(ke(Pt(c)));l>h?(a.unshift(c),h=l):a.push(c)}else a.push(c)}),te(a,t);default:throw new Error("geometry type "+o+" is not supported")}}function Be(e){var t=e[0],i=t[0],n=t[1],r=e[e.length-1],s=r[0],o=r[1];return(i!==s||n!==o)&&e.push(t),e}function un(e){var t=e[0],i=e[1],n=e[2],r=e[3];return Math.abs(t-n)*Math.abs(i-r)}function Et(e,t,i){const r=e.getCenter().lat,s=e.getZoom(),o=r*(Math.PI/180),a=40075017*Math.cos(o)/Math.pow(2,s+9);return t/a}async function fn(e,t,i){const r=await(u=>new Promise((m,y)=>{const w=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),T=URL.createObjectURL(w),v=new Image;v.crossOrigin="anonymous",v.onload=()=>{URL.revokeObjectURL(T),m(v)},v.onerror=O=>{URL.revokeObjectURL(T),y(new Error(`SVG图片加载失败:${JSON.stringify(O)}`))},v.src=T}))(e),s=r.naturalWidth||r.width||300,o=r.naturalHeight||r.height||150,a=document.createElement("canvas");a.width=s,a.height=o;const h=a.getContext("2d");if(!h)throw new Error("无法获取Canvas 2D上下文");h.clearRect(0,0,s,o),h.drawImage(r,0,0,s,o);const[c,l]=await Promise.all([createImageBitmap(a),Promise.resolve(h.getImageData(0,0,s,o))]);return{image:r,bitmap:c,imageData:l}}class ut{static SUCCESS=Qt.SUCCESS;static FAIL=Qt.FAIL;_map;_cache=new be({uniqueKey:`${qi}-icon`,type:"localstorage"});constructor(t){this._map=t}async load(t){const i=await Promise.allSettled(t.map(s=>this.add(s))),n=[],r=[];return i.forEach(s=>{s.status==="fulfilled"?n.push(s.value):r.push(s.reason)}),{success:n,error:r}}async loadSvg(t){const i=await Promise.allSettled(t.map(s=>this.addSvg(s))),n=[],r=[];return i.forEach(s=>{s.status==="fulfilled"?n.push(s.value):r.push(s.reason)}),{success:n,error:r}}async addSvg(t){if(this.has(t.name))return this.error(t,"The image has been loaded!");{const i=await fn(t.svg);return this._cache.set({name:t.name,content:{width:i.image.width,height:i.image.height,image:i.image}}),this._map.addImage(t.name,i.image),this.success(t)}}add(t){return new Promise((i,n)=>{this.has(t.name)?n(this.error(t,"The image has been loaded!")):this._map.loadImage(t.url,(r,s)=>{if(r){n(this.error(t,r));return}if(s)this._cache.set({name:t.name,content:{width:s.width,height:s.height,image:s}}),this._map.addImage(t.name,s,t.options),i(this.success(t));else{n(this.error(t,"The image has not found!"));return}})})}has(t){return this._map.hasImage(t)}getImage(t){return this._cache.get(t)}update(t){return new Promise((i,n)=>{if(!this._map.hasImage(t.name)){n(this.error(t,"The image has not been loaded!"));return}this._map.loadImage(t.url,(r,s)=>{if(r){n(this.error(t,r));return}if(s)this._cache.set({name:t.name,content:{width:s.width,height:s.height}}),this._map.updateImage(t.name,s),i(this.success(t));else{n(this.error(t,"The image has not found!"));return}})})}delete(t){this._map.hasImage(t)&&(this._map.removeImage(t),this._cache.remove(t))}success(t){return{code:ut.SUCCESS,data:t,msg:`The ${t.name} was successfully added`}}error(t,i){return{code:ut.FAIL,data:t,msg:i}}}var ie={exports:{}},ze;function dn(){return ze||(ze=1,(function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(i=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function s(h,c,l,u,m){if(typeof l!="function")throw new TypeError("The listener must be a function");var y=new r(l,u||h,m),w=i?i+c:c;return h._events[w]?h._events[w].fn?h._events[w]=[h._events[w],y]:h._events[w].push(y):(h._events[w]=y,h._eventsCount++),h}function o(h,c){--h._eventsCount===0?h._events=new n:delete h._events[c]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(i?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},a.prototype.listeners=function(c){var l=i?i+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var m=0,y=u.length,w=new Array(y);m<y;m++)w[m]=u[m].fn;return w},a.prototype.listenerCount=function(c){var l=i?i+c:c,u=this._events[l];return u?u.fn?1:u.length:0},a.prototype.emit=function(c,l,u,m,y,w){var T=i?i+c:c;if(!this._events[T])return!1;var v=this._events[T],O=arguments.length,B,S;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),O){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,l),!0;case 3:return v.fn.call(v.context,l,u),!0;case 4:return v.fn.call(v.context,l,u,m),!0;case 5:return v.fn.call(v.context,l,u,m,y),!0;case 6:return v.fn.call(v.context,l,u,m,y,w),!0}for(S=1,B=new Array(O-1);S<O;S++)B[S-1]=arguments[S];v.fn.apply(v.context,B)}else{var Y=v.length,k;for(S=0;S<Y;S++)switch(v[S].once&&this.removeListener(c,v[S].fn,void 0,!0),O){case 1:v[S].fn.call(v[S].context);break;case 2:v[S].fn.call(v[S].context,l);break;case 3:v[S].fn.call(v[S].context,l,u);break;case 4:v[S].fn.call(v[S].context,l,u,m);break;default:if(!B)for(k=1,B=new Array(O-1);k<O;k++)B[k-1]=arguments[k];v[S].fn.apply(v[S].context,B)}}return!0},a.prototype.on=function(c,l,u){return s(this,c,l,u,!1)},a.prototype.once=function(c,l,u){return s(this,c,l,u,!0)},a.prototype.removeListener=function(c,l,u,m){var y=i?i+c:c;if(!this._events[y])return this;if(!l)return o(this,y),this;var w=this._events[y];if(w.fn)w.fn===l&&(!m||w.once)&&(!u||w.context===u)&&o(this,y);else{for(var T=0,v=[],O=w.length;T<O;T++)(w[T].fn!==l||m&&!w[T].once||u&&w[T].context!==u)&&v.push(w[T]);v.length?this._events[y]=v.length===1?v[0]:v:o(this,y)}return this},a.prototype.removeAllListeners=function(c){var l;return c?(l=i?i+c:c,this._events[l]&&o(this,l)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,e.exports=a})(ie)),ie.exports}var pn=dn();const ne=Ne(pn);var Ye=typeof global=="object"&&global&&global.Object===Object&&global,mn=typeof self=="object"&&self&&self.Object===Object&&self,q=Ye||mn||Function("return this")(),ft=q.Symbol,je=Object.prototype,gn=je.hasOwnProperty,yn=je.toString,Lt=ft?ft.toStringTag:void 0;function vn(e){var t=gn.call(e,Lt),i=e[Lt];try{e[Lt]=void 0;var n=!0}catch{}var r=yn.call(e);return n&&(t?e[Lt]=i:delete e[Lt]),r}var xn=Object.prototype,wn=xn.toString;function _n(e){return wn.call(e)}var bn="[object Null]",Sn="[object Undefined]",Xe=ft?ft.toStringTag:void 0;function dt(e){return e==null?e===void 0?Sn:bn:Xe&&Xe in Object(e)?vn(e):_n(e)}function Ft(e){return e!=null&&typeof e=="object"}var Mn="[object Symbol]";function re(e){return typeof e=="symbol"||Ft(e)&&dt(e)==Mn}function En(e,t){for(var i=-1,n=e==null?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r}var Bt=Array.isArray,Ue=ft?ft.prototype:void 0,He=Ue?Ue.toString:void 0;function qe(e){if(typeof e=="string")return e;if(Bt(e))return En(e,qe)+"";if(re(e))return He?He.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function zt(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Ln="[object AsyncFunction]",Cn="[object Function]",An="[object GeneratorFunction]",In="[object Proxy]";function Ze(e){if(!zt(e))return!1;var t=dt(e);return t==Cn||t==An||t==Ln||t==In}var se=q["__core-js_shared__"],Ge=(function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();function Tn(e){return!!Ge&&Ge in e}var On=Function.prototype,kn=On.toString;function W(e){if(e!=null){try{return kn.call(e)}catch{}try{return e+""}catch{}}return""}var Nn=/[\\^$.*+?()[\]{}|]/g,$n=/^\[object .+?Constructor\]$/,Dn=Function.prototype,Pn=Object.prototype,Rn=Dn.toString,Fn=Pn.hasOwnProperty,Bn=RegExp("^"+Rn.call(Fn).replace(Nn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zn(e){if(!zt(e)||Tn(e))return!1;var t=Ze(e)?Bn:$n;return t.test(W(e))}function Yn(e,t){return e?.[t]}function V(e,t){var i=Yn(e,t);return zn(i)?i:void 0}var oe=V(q,"WeakMap"),Je=(function(){try{var e=V(Object,"defineProperty");return e({},"",{}),e}catch{}})(),jn=9007199254740991,Xn=/^(?:0|[1-9]\d*)$/;function Un(e,t){var i=typeof e;return t=t??jn,!!t&&(i=="number"||i!="symbol"&&Xn.test(e))&&e>-1&&e%1==0&&e<t}function Hn(e,t,i){t=="__proto__"&&Je?Je(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function Ke(e,t){return e===t||e!==e&&t!==t}var qn=Object.prototype,Zn=qn.hasOwnProperty;function Gn(e,t,i){var n=e[t];(!(Zn.call(e,t)&&Ke(n,i))||i===void 0&&!(t in e))&&Hn(e,t,i)}var Jn=9007199254740991;function We(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Jn}function Kn(e){return e!=null&&We(e.length)&&!Ze(e)}var Wn=Object.prototype;function Ve(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||Wn;return e===i}var Vn="[object Arguments]";function Qe(e){return Ft(e)&&dt(e)==Vn}var ti=Object.prototype,Qn=ti.hasOwnProperty,tr=ti.propertyIsEnumerable,er=Qe((function(){return arguments})())?Qe:function(e){return Ft(e)&&Qn.call(e,"callee")&&!tr.call(e,"callee")};function ir(){return!1}var ei=typeof M=="object"&&M&&!M.nodeType&&M,ii=ei&&typeof module=="object"&&module&&!module.nodeType&&module,nr=ii&&ii.exports===ei,ni=nr?q.Buffer:void 0,rr=ni?ni.isBuffer:void 0,sr=rr||ir,or="[object Arguments]",ar="[object Array]",cr="[object Boolean]",hr="[object Date]",lr="[object Error]",ur="[object Function]",fr="[object Map]",dr="[object Number]",pr="[object Object]",mr="[object RegExp]",gr="[object Set]",yr="[object String]",vr="[object WeakMap]",xr="[object ArrayBuffer]",wr="[object DataView]",_r="[object Float32Array]",br="[object Float64Array]",Sr="[object Int8Array]",Mr="[object Int16Array]",Er="[object Int32Array]",Lr="[object Uint8Array]",Cr="[object Uint8ClampedArray]",Ar="[object Uint16Array]",Ir="[object Uint32Array]",C={};C[_r]=C[br]=C[Sr]=C[Mr]=C[Er]=C[Lr]=C[Cr]=C[Ar]=C[Ir]=!0,C[or]=C[ar]=C[xr]=C[cr]=C[wr]=C[hr]=C[lr]=C[ur]=C[fr]=C[dr]=C[pr]=C[mr]=C[gr]=C[yr]=C[vr]=!1;function Tr(e){return Ft(e)&&We(e.length)&&!!C[dt(e)]}function Or(e){return function(t){return e(t)}}var ri=typeof M=="object"&&M&&!M.nodeType&&M,Ct=ri&&typeof module=="object"&&module&&!module.nodeType&&module,kr=Ct&&Ct.exports===ri,ae=kr&&Ye.process,si=(function(){try{var e=Ct&&Ct.require&&Ct.require("util").types;return e||ae&&ae.binding&&ae.binding("util")}catch{}})(),oi=si&&si.isTypedArray,Nr=oi?Or(oi):Tr;function $r(e,t){return function(i){return e(t(i))}}var Dr=$r(Object.keys,Object),Pr=Object.prototype,Rr=Pr.hasOwnProperty;function Fr(e){if(!Ve(e))return Dr(e);var t=[];for(var i in Object(e))Rr.call(e,i)&&i!="constructor"&&t.push(i);return t}var Br=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zr=/^\w*$/;function Yr(e,t){if(Bt(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||re(e)?!0:zr.test(e)||!Br.test(e)||t!=null&&e in Object(t)}var At=V(Object,"create");function jr(){this.__data__=At?At(null):{},this.size=0}function Xr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ur="__lodash_hash_undefined__",Hr=Object.prototype,qr=Hr.hasOwnProperty;function Zr(e){var t=this.__data__;if(At){var i=t[e];return i===Ur?void 0:i}return qr.call(t,e)?t[e]:void 0}var Gr=Object.prototype,Jr=Gr.hasOwnProperty;function Kr(e){var t=this.__data__;return At?t[e]!==void 0:Jr.call(t,e)}var Wr="__lodash_hash_undefined__";function Vr(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=At&&t===void 0?Wr:t,this}function Q(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}Q.prototype.clear=jr,Q.prototype.delete=Xr,Q.prototype.get=Zr,Q.prototype.has=Kr,Q.prototype.set=Vr;function Qr(){this.__data__=[],this.size=0}function Yt(e,t){for(var i=e.length;i--;)if(Ke(e[i][0],t))return i;return-1}var ts=Array.prototype,es=ts.splice;function is(e){var t=this.__data__,i=Yt(t,e);if(i<0)return!1;var n=t.length-1;return i==n?t.pop():es.call(t,i,1),--this.size,!0}function ns(e){var t=this.__data__,i=Yt(t,e);return i<0?void 0:t[i][1]}function rs(e){return Yt(this.__data__,e)>-1}function ss(e,t){var i=this.__data__,n=Yt(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this}function pt(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}pt.prototype.clear=Qr,pt.prototype.delete=is,pt.prototype.get=ns,pt.prototype.has=rs,pt.prototype.set=ss;var jt=V(q,"Map");function os(){this.size=0,this.__data__={hash:new Q,map:new(jt||pt),string:new Q}}function as(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Xt(e,t){var i=e.__data__;return as(t)?i[typeof t=="string"?"string":"hash"]:i.map}function cs(e){var t=Xt(this,e).delete(e);return this.size-=t?1:0,t}function hs(e){return Xt(this,e).get(e)}function ls(e){return Xt(this,e).has(e)}function us(e,t){var i=Xt(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this}function tt(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}tt.prototype.clear=os,tt.prototype.delete=cs,tt.prototype.get=hs,tt.prototype.has=ls,tt.prototype.set=us;var fs="Expected a function";function ce(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(fs);var i=function(){var n=arguments,r=t?t.apply(this,n):n[0],s=i.cache;if(s.has(r))return s.get(r);var o=e.apply(this,n);return i.cache=s.set(r,o)||s,o};return i.cache=new(ce.Cache||tt),i}ce.Cache=tt;var ds=500;function ps(e){var t=ce(e,function(n){return i.size===ds&&i.clear(),n}),i=t.cache;return t}var ms=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gs=/\\(\\)?/g,ys=ps(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(ms,function(i,n,r,s){t.push(r?s.replace(gs,"$1"):n||i)}),t});function vs(e){return e==null?"":qe(e)}function xs(e,t){return Bt(e)?e:Yr(e,t)?[e]:ys(vs(e))}function ws(e){if(typeof e=="string"||re(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}var he=V(q,"DataView"),le=V(q,"Promise"),ue=V(q,"Set"),ai="[object Map]",_s="[object Object]",ci="[object Promise]",hi="[object Set]",li="[object WeakMap]",ui="[object DataView]",bs=W(he),Ss=W(jt),Ms=W(le),Es=W(ue),Ls=W(oe),et=dt;(he&&et(new he(new ArrayBuffer(1)))!=ui||jt&&et(new jt)!=ai||le&&et(le.resolve())!=ci||ue&&et(new ue)!=hi||oe&&et(new oe)!=li)&&(et=function(e){var t=dt(e),i=t==_s?e.constructor:void 0,n=i?W(i):"";if(n)switch(n){case bs:return ui;case Ss:return ai;case Ms:return ci;case Es:return hi;case Ls:return li}return t});var Cs="[object Map]",As="[object Set]",Is=Object.prototype,Ts=Is.hasOwnProperty;function Os(e){if(e==null)return!0;if(Kn(e)&&(Bt(e)||typeof e=="string"||typeof e.splice=="function"||sr(e)||Nr(e)||er(e)))return!e.length;var t=et(e);if(t==Cs||t==As)return!e.size;if(Ve(e))return!Fr(e).length;for(var i in e)if(Ts.call(e,i))return!1;return!0}function ks(e,t,i,n){if(!zt(e))return e;t=xs(t,e);for(var r=-1,s=t.length,o=s-1,a=e;a!=null&&++r<s;){var h=ws(t[r]),c=i;if(h==="__proto__"||h==="constructor"||h==="prototype")return e;if(r!=o){var l=a[h];c=void 0,c===void 0&&(c=zt(l)?l:Un(t[r+1])?[]:{})}Gn(a,h,c),a=a[h]}return e}function Ns(e,t,i){return e==null?e:ks(e,t,i)}const D=[];for(let e=0;e<256;++e)D.push((e+256).toString(16).slice(1));function $s(e,t=0){return(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase()}let fe;const Ds=new Uint8Array(16);function Ps(){if(!fe){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fe=crypto.getRandomValues.bind(crypto)}return fe(Ds)}const fi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function di(e,t,i){if(fi.randomUUID&&!e)return fi.randomUUID();e=e||{};const n=e.random??e.rng?.()??Ps();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,$s(n)}class pi{map;sourceData=new Map;dirtySourceIds=new Set;renderFrameId=null;constructor(t){this.map=t}addSource(t,i){this.map.getSource(t)||(i.type==="geojson"&&i.promoteId,this.map.addSource(t,i))}addLayer(t,i){this.map.getLayer(t.id)||this.map.addLayer(t,i)}findFeature(t,i){return this.sourceData.get(t)?.features.find(r=>r.id===i)}getSource(t){return this.map.getSource(t)}setGeoJSONData(t,i){const n=Array.isArray(i)?i:[i];let r=this.sourceData.get(t);r||(r={type:"FeatureCollection",features:[]},this.sourceData.set(t,r)),n.forEach(s=>{if(Os(s.id))return;const o=r.features.findIndex(a=>a.id===s.id);s.geometry===null?o>-1&&r.features.splice(o,1):o>-1?r.features[o]=s:r.features.push(s)}),this.dirtySourceIds.add(t),this.scheduleRender()}scheduleRender(){this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.flushUpdates(),this.renderFrameId=null}))}flushUpdates(){this.dirtySourceIds.forEach(t=>{const i=this.getSource(t),n=this.sourceData.get(t);i?.type==="geojson"&&n&&i.setData({...n,features:[...n.features]})}),this.dirtySourceIds.clear()}setState(t,i,n){this.map.setFeatureState({source:t,id:i},n)}getState(t,i){return this.map.getFeatureState({source:t,id:i})}destroy(){this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.sourceData.clear(),this.dirtySourceIds.clear()}}const de="mapbox-gl-focus-source",Rs={id:"mapbox-gl-focus-layer",type:"line",source:de,paint:{"line-color":"#f00","line-width":3},layout:{}};class Fs extends ne{map;focusItems=[];register;zoomendFunc=this._zoomend.bind(this);constructor(t){super(),this.map=t,this.register=new pi(t),this.onAdd()}get features(){return this.focusItems.map(t=>t.border)}onAdd(){this.register.addSource(de,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),this.register.addLayer(Rs)}onRemove(){this.removeAll()}set(t,i){const n=t.id??di();return this._onHandle(n,t,i),n}get(t){return this.focusItems.find(i=>i.id===t)}remove(t){const i=this.focusItems.findIndex(n=>n.id===t);i!==-1&&this.focusItems.splice(i,1),this.render()}removeAll(){this.focusItems=[],this.render()}render(){const t=this.map.getSource(de);t&&(this.features.length>0?t.updateData({type:"FeatureCollection",features:this.features}):t.setData({type:"FeatureCollection",features:this.features}))}_zoomend(){this.render()}_onHandle(t,i,n){const r=this.getFocusBorder(i,n),s={id:t,border:r,feature:i,options:n},o=this.focusItems.findIndex(a=>a.id===t);o!==-1?Ns(this.focusItems,o,s):this.focusItems.push(s),this.render(),this.features.length>0?this.map.on("zoomend",this.zoomendFunc):this.map.off("zoomend",this.zoomendFunc)}getFocusBorder(t,i={}){const n=String(t.id??di()),{padding:r=10,armLength:s=20,size:o=40}=i,a=ke(t),h=1/Et(this.map,1);let c=a,l=0;if(t.geometry.type==="Point"){const m=(o+r)/2*h;l=o*.3*h,c=this._expandBBox(a,m,a[1])}else{const u=r*h;l=s*h,c=this._expandBBox(a,u,a[1])}return this._createBracketGeometry(n,c,l)}_expandBBox(t,i,n){const[r,s,o,a]=t,c=i/111319,l=c/Math.cos(n*Math.PI/180);return[r-l,s-c,o+l,a+c]}_createBracketGeometry(t,i,n){const[r,s,o,a]=i,c=n/111319,l=s*Math.PI/180,u=c/Math.cos(l),m=Math.min(c,(a-s)/2),y=Math.min(u,(o-r)/2),w=[[[r+y,s],[r,s],[r,s+m]],[[r,a-m],[r,a],[r+y,a]],[[o-y,a],[o,a],[o,a-m]],[[o,s+m],[o,s],[o-y,s]]];return Zi(w,{id:t},{id:t})}}class mi{map;events;register;iconManage;focus;constructor(t){this.map=t.map,this.events=new ne,this.register=new pi(this.map),this.iconManage=new ut(this.map),this.focus=new Fs(this.map)}destroy(){this.events.removeAllListeners()}}const pe=new WeakMap;function Bs(e){const t=pe.get(e);if(t)return t;const i=new mi({map:e});return pe.set(e,i),e.once("remove",()=>{i.destroy(),pe.delete(e)}),i}class mt{context;constructor(t){this.context=Bs(t),this.onAdd(),this.context.map.once("beforeRemove",()=>{this.onRemove()})}emit(){this.context.events.emit("")}mount(){this.onAdd()}destroy(){this.onRemove()}}const zs="mapbox-gl-tooltip-connect-line",Ys="mapbox-gl-tooltip-connect-debug-line",js="mapbox-gl-tooltip-connect-debug-fill",it="mapbox-gl-tooltip-source",Xs=[{id:zs,source:it,type:"line",paint:{"line-color":"#000","line-width":1}},{id:js,source:it,type:"fill",filter:["all",["==","meta","debug"]],paint:{"fill-color":"#f00","fill-opacity":0}},{id:Ys,source:it,type:"line",filter:["all",["==","meta","debug"]],paint:{"line-color":"#f00","line-width":1}}];class It extends mt{static DEBUG=!1;options;mark=null;zoom=()=>{this.render()};constructor(t,i){super(t),this.options=i,this.visible&&(this.context.map.on("zoom",this.zoom),this.context.map.on("zoomend",this.zoom))}get id(){return this.options.id}get visible(){const t=this.context.map.getBounds();return!!this.options.visible&&!!t?.contains(this.options.position)}get bbox(){const t=this.getAllBbox(),i=this.options.anchor??"bottom-right";return t[i]}onAdd(){this.context.register.addSource(it,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),Xs.forEach(t=>{this.context.register.addLayer(t)})}onRemove(){this.remove()}debug(){const{minX:t,minY:i,maxX:n,maxY:r}=this.bbox,{lng:s,lat:o}=this.context.map.unproject(new A.Point(t,i)),{lng:a,lat:h}=this.context.map.unproject(new A.Point(n,r)),c=en([s,o,a,h],{properties:{meta:"debug"},id:String(this.id)+"debug"});this.context.register.setGeoJSONData(it,c)}hide(){this.options.visible=!1,this.render(),this.context.map.off("zoom",this.zoom),this.context.map.off("zoomend",this.zoom)}show(){this.options.visible=!0,this.render(),this.context.map.on("zoom",this.zoom),this.context.map.on("zoomend",this.zoom)}setAnchor(t){this.mark&&(this.mark.remove(),this.mark=null),this.options.anchor=t,this.show()}getSimpleBbox(){return{"top-left":this.getBbox("top-left"),"top-right":this.getBbox("top-right"),"bottom-left":this.getBbox("bottom-left"),"bottom-right":this.getBbox("bottom-right")}}getAllBbox(){return{"top-left":this.getBbox("top-left"),"top-right":this.getBbox("top-right"),"bottom-left":this.getBbox("bottom-left"),"bottom-right":this.getBbox("bottom-right")}}getBbox(t){const i=t??this.options.anchor,n=this.context.map.project(this.options.position),r=new A.Point(this.options.offsetX??0,this.options.offsetY??0),{width:s,height:o}=this.getOffDOMSize(this.options.element),a={minX:n.x,minY:n.y,maxX:n.x,maxY:n.y};return i==="top-left"?(a.maxY=n.y+o+Math.abs(r.y),a.maxX=n.x+s+Math.abs(r.x)):i==="top-right"?(a.maxY=n.y+o+Math.abs(r.y),a.minX=n.x-(s+r.x)):i==="bottom-left"?(a.minY=n.y-(o+r.y),a.maxX=n.x+s+Math.abs(r.x)):i==="bottom-right"&&(a.minY=n.y-(o+r.y),a.minX=n.x-(s+r.x)),a}getOffDOMSize(t){const i=t.cloneNode(!0),n={position:i.style.position,visibility:i.style.visibility,top:i.style.top,left:i.style.left,display:i.style.display};i.style.position="absolute",i.style.visibility="hidden",i.style.top="-9999px",i.style.left="-9999px",i.style.display="block",this.context.map.getCanvasContainer().appendChild(i);const r=i.offsetWidth,s=i.offsetHeight;return this.context.map.getCanvasContainer().removeChild(i),i.style.position=n.position,i.style.visibility=n.visibility,i.style.top=n.top,i.style.left=n.left,i.style.display=n.display,{width:r,height:s}}remove(){this.options.visible=!1,this.context.map.off("zoom",this.zoom),this.context.map.off("zoomend",this.zoom),console.log("remove"),this.mark&&(this.mark.remove(),this.mark=null),this.connectLine()}_create(){this.mark=new A.Marker({className:this.options.className??"mapbox-gl-tooltip",element:this.options.element,offset:this._getOffsetByAnchor(),anchor:this.options.anchor}).setLngLat(this.options.position)}_getOffsetByAnchor(){const t=new A.Point(0,0);return this.options.anchor==="top-left"?(t.x=this.options.offsetX??0,t.y=this.options.offsetY??0):this.options.anchor==="top-right"?(t.x=-(this.options.offsetX??0),t.y=this.options.offsetY??0):this.options.anchor==="bottom-left"?(t.x=this.options.offsetX??0,t.y=-(this.options.offsetY??0)):this.options.anchor==="bottom-right"&&(t.x=-(this.options.offsetX??0),t.y=-(this.options.offsetY??0)),t}setLngLat(t){return this.options.position=t,this.mark&&this.mark.setLngLat(t),this}connectLine(){const t=`${String(this.options.id)}-tooltip-connect-line`,i=this.connectPoint();if(!i||!this.visible){const s={type:"Feature",geometry:{type:"Point",coordinates:[0,0]},id:t,properties:{}};this.context.register.setGeoJSONData(it,s);return}const n=[this.options.position.toArray(),i.toArray()],r=Pt(n,{},{id:t});this.context.register.setGeoJSONData(it,r)}connectPoint(){if(!this.mark||!this.visible)return null;const t=this.context.map.project(this.mark.getLngLat()),i=this.mark.getOffset();t.x+=i.x,t.y+=i.y;const{width:n}=this.getOffDOMSize(this.options.element);return this.options.anchor==="top-left"?t.x+=n/2:this.options.anchor==="top-right"?t.x-=n/2:this.options.anchor==="bottom-left"?t.x+=n/2:this.options.anchor==="bottom-right"&&(t.x-=n/2),this.context.map.unproject(t)}render(){return this.visible?(this.mark||this._create(),this.mark?.addTo(this.context.map),It.DEBUG&&this.debug()):(this.mark?.remove(),this.mark=null),this.connectLine(),this}}const j="Ais",gt="mapbox-gl-ship-source",Z="mapbox-gl-ship-icon-layer",G="mapbox-gl-ship-real-layer",gi="mapbox-gl-ship-real-outline-layer",Us=.2,Hs=.5;var H=(e=>(e.ONLINE="Online",e.DELAY="Delay",e.OFFLINE="Offline",e))(H||{}),Tt=(e=>(e.ONLINE="#03CC02",e.DELAY="#FFFD6C",e.OFFLINE="#999999",e))(Tt||{});const yi={id:Z,source:gt,filter:["==","$type","Point"],type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":["get","icon"],"icon-rotate":["get","direction"],"icon-size":["interpolate",["linear"],["zoom"],0,["coalesce",["get","minIconSize"],.2],19,["coalesce",["get","maxIconSize"],.5]]}},vi={id:G,source:gt,type:"fill",layout:{},paint:{"fill-color":["case",["==",["get","updateStatus"],"Online"],"#03CC02",["==",["get","updateStatus"],"Delay"],"#FFFD6C",["==",["get","updateStatus"],"Offline"],"#999999","#999999"]}},xi={id:gi,source:gt,type:"line",layout:{},paint:{"line-color":["case",["boolean",["feature-state","hover"],!1],"#f00",["boolean",["feature-state","focus"],!1],"#f00","#000"],"line-width":2}},wi=[yi,vi,xi],_i=[{name:`${j}-$color-static`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<svg width="33px" height="49px" viewBox="0 0 33 49" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
3
|
<title>delay_nospeed</title>
|
|
4
4
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<path d="M16.5,3.13354433 L31.6080922,48 L1.39190779,48 L16.5,3.13354433 Z" id="三角形"></path>
|
|
7
7
|
</g>
|
|
8
8
|
</g>
|
|
9
|
-
</svg>`},{name:`${
|
|
9
|
+
</svg>`},{name:`${j}-$color-static-active`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
10
10
|
<svg width="33px" height="49px" viewBox="0 0 33 49" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
11
11
|
<title>delay_nospeed_select</title>
|
|
12
12
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<path d="M16.5,3.13354433 L31.6080922,48 L1.39190779,48 L16.5,3.13354433 Z" id="三角形"></path>
|
|
15
15
|
</g>
|
|
16
16
|
</g>
|
|
17
|
-
</svg>`},{name:`${
|
|
17
|
+
</svg>`},{name:`${j}-$color-straight`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
18
18
|
<svg width="33px" height="87px" viewBox="0 0 33 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
19
19
|
<title>delay_straight</title>
|
|
20
20
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<line x1="16.5" y1="0.5" x2="16.5" y2="41.5" id="直线" stroke-linecap="square"></line>
|
|
24
24
|
</g>
|
|
25
25
|
</g>
|
|
26
|
-
</svg>`},{name:`${
|
|
26
|
+
</svg>`},{name:`${j}-$color-straight-active`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
27
27
|
<svg width="33px" height="87px" viewBox="0 0 33 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
28
28
|
<title>delay_straight_select</title>
|
|
29
29
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
<line x1="16.5" y1="0.5" x2="16.5" y2="41.5" id="直线" stroke-linecap="square"></line>
|
|
33
33
|
</g>
|
|
34
34
|
</g>
|
|
35
|
-
</svg>`},{name:`${
|
|
35
|
+
</svg>`},{name:`${j}-$color-left`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
36
36
|
<svg width="40px" height="87px" viewBox="0 0 40 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
37
37
|
<title>delay_left</title>
|
|
38
38
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
<line x1="16.5" y1="0.5" x2="38.5" y2="0.5" id="直线-2" stroke-linecap="square"></line>
|
|
43
43
|
</g>
|
|
44
44
|
</g>
|
|
45
|
-
</svg>`},{name:`${
|
|
45
|
+
</svg>`},{name:`${j}-$color-left-active`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
46
46
|
<svg width="41px" height="87px" viewBox="0 0 41 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
47
47
|
<title>delay_left_select</title>
|
|
48
48
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<line x1="17" y1="0.5" x2="39" y2="0.5" id="直线-2" stroke-linecap="square"></line>
|
|
53
53
|
</g>
|
|
54
54
|
</g>
|
|
55
|
-
</svg>`},{name:`${
|
|
55
|
+
</svg>`},{name:`${j}-$color-right`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
56
56
|
<svg width="40px" height="87px" viewBox="0 0 40 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
57
57
|
<title>delay_right</title>
|
|
58
58
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
<line x1="16.5" y1="0.5" x2="38.5" y2="0.5" id="直线-2" stroke-linecap="square"></line>
|
|
63
63
|
</g>
|
|
64
64
|
</g>
|
|
65
|
-
</svg>`},{name:`${
|
|
65
|
+
</svg>`},{name:`${j}-$color-right-active`,svg:`<?xml version="1.0" encoding="UTF-8"?>
|
|
66
66
|
<svg width="40px" height="87px" viewBox="0 0 40 87" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
67
67
|
<title>delay_right_select</title>
|
|
68
68
|
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
<line x1="17" y1="0.5" x2="39" y2="0.5" id="直线-2" stroke-linecap="square"></line>
|
|
73
73
|
</g>
|
|
74
74
|
</g>
|
|
75
|
-
</svg>`}];var Gt=(e=>(e.LAND="land",e.SATELLITE="satellite",e))(Gt||{});const Hi={version:8,name:"Basic",glyphs:"https://sdkinteligenceberth.zhonganhse.com:21333/app/font/{fontstack}/{range}.pbf",sources:{base:{tiles:["http://tianditu.ehanghai.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=468826a92a07c852cefab31f9bed06d4"],type:"raster",tileSize:256,minzoom:0,maxzoom:17},label:{tiles:["http://tianditu.ehanghai.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=468826a92a07c852cefab31f9bed06d4"],type:"raster",tileSize:256,minzoom:0,maxzoom:217}},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(212,234,238,1)"}},{id:"base_layer",source:"base",type:"raster"},{id:"label_layer",source:"label",type:"raster"},{id:"base-end",type:"background",paint:{"background-color":"transparent"}},{id:"point-end",type:"background",paint:{"background-color":"transparent"}}]};class qi extends Bt{map;options;cache=new Set;timer=null;originalRemove;icon;static LAND=Gt.LAND;static SATELLITE=Gt.SATELLITE;constructor(t){super(),this.options=t,I.Map.prototype._authenticate=()=>{},this.map=new I.Map({...this.options,style:Hi}),this.icon=new tt(this.map),this.originalRemove=this.map.remove.bind(this.map),this.map.remove=()=>{this.map.fire("beforeRemove",{cancel:n=>{n||this.originalRemove()}})},this.map.once("load",()=>{ji.forEach(async n=>{await Promise.all([this.icon.addSvg({name:n.name.replace("$color",z.ONLINE),svg:n.svg.replace("$color",Et.ONLINE)}),this.icon.addSvg({name:n.name.replace("$color",z.DELAY),svg:n.svg.replace("$color",Et.DELAY)}),this.icon.addSvg({name:n.name.replace("$color",z.OFFLINE),svg:n.svg.replace("$color",Et.OFFLINE)})])}),this.emit("loaded",this.map)})}getMap(){return this.map}zoomIn(){this.getMap().isZooming()||this.getMap().zoomIn()}zoomOut(){this.getMap().isZooming()||this.getMap().zoomOut()}mapLoaded(){const t=n=>{this.getMap()._loaded?(this.timer&&(clearInterval(this.timer),this.timer=null),this.cache.size>0&&(this.cache.forEach(i=>{i(this.getMap())}),this.cache.clear()),n(this.getMap())):this.timer?this.cache.add(n):this.timer=setInterval(()=>{t(n)},16)};return new Promise((n,i)=>{try{t(n)}catch(s){this.timer&&(clearInterval(this.timer),this.timer=null),i(new Error(`mapLoaded错误:${s}`))}})}}var Lt=(e=>(e.ON="On",e.OFF="Off",e))(Lt||{});class it extends dt{status=Lt.OFF;static ON=Lt.ON;static OFF=Lt.OFF;constructor(t){super(t)}switch(){return this.status===it.ON?(this.status=it.OFF,this.off()):this.status===it.OFF&&(this.status=it.ON,this.on()),this.status}}class Zi extends it{ships=[];hoverId=null;_click=()=>{};_move=()=>{};_leave=()=>{};_zoomEnd=()=>{};constructor(t,n){super(t),n&&(this.ships=n)}on(){this.context.map.on("click",Z,this._click),this.context.map.on("mousemove",Z,this._move),this.context.map.on("mouseleave",Z,this._leave),this.context.map.on("click",J,this._click),this.context.map.on("mousemove",J,this._move),this.context.map.on("mouseleave",J,this._leave),this.context.map.on("zoomend",this._zoomEnd)}off(){this.context.map.off("click",Z,this._click),this.context.map.off("mousemove",Z,this._move),this.context.map.off("mouseleave",Z,this._leave),this.context.map.off("click",J,this._click),this.context.map.off("mousemove",J,this._move),this.context.map.off("mouseleave",J,this._leave),this.context.map.off("zoomend",this._zoomEnd)}onAdd(){this._click=this.onClick.bind(this),this._move=this.onMove.bind(this),this._leave=this.onLeave.bind(this),this._zoomEnd=this.onZoomEnd.bind(this),this.on()}onRemove(){this.off()}add(t){const n=this.findShip(t.id);n?t.update(n.options):this.ships.push(t)}remove(t){const n=this.ships.findIndex(i=>i.id===t);n!==-1&&this.ships.splice(n,1)}onZoomEnd(){this.ships.forEach(t=>{t.render()})}onMove(t){if(t.features?.length){if(this.context.map.getCanvasContainer().style.cursor="pointer",this.hoverId===t.features[0].id)return;this.hoverId&&this.unhover(),this.hoverId=t.features[0].id,this.hover()}}onLeave(){this.unhover(),this.hoverId=null,this.context.map.getCanvasContainer().style.cursor=""}onClick(t){if(t.features?.length){const n=t.features[0].id;if(n){const i=this.findShip(n);i?.focus(),console.log(i,"ship"),this.context.events.emit("click",i)}}}hover(){if(!this.hoverId)return;const t=this.findShip(this.hoverId);t?.setState({hover:!0}),t?.render(),this.context.events.emit("hover",t)}unhover(){if(!this.hoverId)return;const t=this.findShip(this.hoverId);t?.setState({hover:!1}),t?.render(),this.context.events.emit("unhover",t)}findShip(t){return this.ships.find(n=>String(n.id)===String(t))}}class Ji extends dt{options;ships=[];event;pluginRegistry=new Map;collision;constructor(t,n){super(t),this.options=n,this.collision=new ne(this.context.map),this.event=new Zi(t),this.registerPlugins(n.plugins)}onAdd(){}onRemove(){}get tooltips(){return this.ships.flatMap(t=>t.tooltip??[])}registerPlugins(t=[]){t.forEach(n=>{console.log(n.prototype,"PluginClass"),n.NAME?this.pluginRegistry.set(n.NAME,n):console.warn("Ship Plugin missing static NAME property:",n)})}createCollisions(){return this.tooltips.map(t=>({...t.getAllBbox(),id:t.id}))}collisionTooltip(){this.collision.load(this.createCollisions()).forEach(t=>{const n=this.tooltips.find(i=>i.id===t.id);n&&(t.visible?n.setAnchor(t.dir):n.hide())})}add(t){const n=this.pluginRegistry.get(t.type);if(!n){console.warn(`No plugin registered for ship type: "${t.type}"`);return}const i=new n(this.context.map,t);return this.ships.push(i),this.event.add(i),i}load(t){this.removeAll();const n=[];return t.forEach(i=>{const s=this.add(i);s&&n.push(s)}),this.render(),this.collisionTooltip(),n}remove(t){this.event.remove(t);const n=this.ships.findIndex(i=>i.id===t);n!==-1&&(this.ships[n].remove(),this.ships.splice(n,1))}removeAll(){this.collision.clear(),this.ships.forEach(t=>{t.remove()}),this.ships=[]}render(){this.ships.forEach(t=>{t.render()})}get(t){return this.ships.find(n=>n.id===t)}select(t){const n=this.get(t);n&&n.select()}unselect(t){const n=this.get(t);n&&n.unselect()}}class It extends dt{options;SOURCE="mapbox-gl-ship-source";static NAME="Base";tooltip=null;visible=!0;constructor(t,n){super(t),this.options=n}destroy(){throw new Error("Method not implemented.")}get isFocus(){const t=this.getState();return t?!!t.focus:!1}setState(t){this.context.map.setFeatureState({source:this.SOURCE,id:this.id},t)}getState(){return this.context.map.getFeatureState({source:this.SOURCE,id:this.id})}isSelf(t){if(t.features&&t.features.length>0){const n=t.features[0];return String(n.id)===this.id}else return!1}getName(){return It.NAME}}var $t={exports:{}},Gi=$t.exports,Pe;function Wi(){return Pe||(Pe=1,(function(e,t){(function(n,i){e.exports=i()})(Gi,(function(){var n=1e3,i=6e4,s=36e5,r="millisecond",a="second",o="minute",c="hour",h="day",l="week",u="month",g="quarter",x="year",w="date",$="Invalid Date",y=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,O=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,T={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(v){var d=["th","st","nd","rd"],f=v%100;return"["+v+(d[(f-20)%10]||d[f]||d[0])+"]"}},M=function(v,d,f){var m=String(v);return!m||m.length>=d?v:""+Array(d+1-m.length).join(f)+v},R={s:M,z:function(v){var d=-v.utcOffset(),f=Math.abs(d),m=Math.floor(f/60),p=f%60;return(d<=0?"+":"-")+M(m,2,"0")+":"+M(p,2,"0")},m:function v(d,f){if(d.date()<f.date())return-v(f,d);var m=12*(f.year()-d.year())+(f.month()-d.month()),p=d.clone().add(m,u),_=f-p<0,b=d.clone().add(m+(_?-1:1),u);return+(-(m+(f-p)/(_?p-b:b-p))||0)},a:function(v){return v<0?Math.ceil(v)||0:Math.floor(v)},p:function(v){return{M:u,y:x,w:l,d:h,D:w,h:c,m:o,s:a,ms:r,Q:g}[v]||String(v||"").toLowerCase().replace(/s$/,"")},u:function(v){return v===void 0}},A="en",G={};G[A]=T;var ke="$isDayjsObject",Kt=function(v){return v instanceof At||!(!v||!v[ke])},Ot=function v(d,f,m){var p;if(!d)return A;if(typeof d=="string"){var _=d.toLowerCase();G[_]&&(p=_),f&&(G[_]=f,p=_);var b=d.split("-");if(!p&&b.length>1)return v(b[0])}else{var E=d.name;G[E]=d,p=E}return!m&&p&&(A=p),p||!m&&A},P=function(v,d){if(Kt(v))return v.clone();var f=typeof d=="object"?d:{};return f.date=v,f.args=arguments,new At(f)},S=R;S.l=Ot,S.i=Kt,S.w=function(v,d){return P(v,{locale:d.$L,utc:d.$u,x:d.$x,$offset:d.$offset})};var At=(function(){function v(f){this.$L=Ot(f.locale,null,!0),this.parse(f),this.$x=this.$x||f.x||{},this[ke]=!0}var d=v.prototype;return d.parse=function(f){this.$d=(function(m){var p=m.date,_=m.utc;if(p===null)return new Date(NaN);if(S.u(p))return new Date;if(p instanceof Date)return new Date(p);if(typeof p=="string"&&!/Z$/i.test(p)){var b=p.match(y);if(b){var E=b[2]-1||0,L=(b[7]||"0").substring(0,3);return _?new Date(Date.UTC(b[1],E,b[3]||1,b[4]||0,b[5]||0,b[6]||0,L)):new Date(b[1],E,b[3]||1,b[4]||0,b[5]||0,b[6]||0,L)}}return new Date(p)})(f),this.init()},d.init=function(){var f=this.$d;this.$y=f.getFullYear(),this.$M=f.getMonth(),this.$D=f.getDate(),this.$W=f.getDay(),this.$H=f.getHours(),this.$m=f.getMinutes(),this.$s=f.getSeconds(),this.$ms=f.getMilliseconds()},d.$utils=function(){return S},d.isValid=function(){return this.$d.toString()!==$},d.isSame=function(f,m){var p=P(f);return this.startOf(m)<=p&&p<=this.endOf(m)},d.isAfter=function(f,m){return P(f)<this.startOf(m)},d.isBefore=function(f,m){return this.endOf(m)<P(f)},d.$g=function(f,m,p){return S.u(f)?this[m]:this.set(p,f)},d.unix=function(){return Math.floor(this.valueOf()/1e3)},d.valueOf=function(){return this.$d.getTime()},d.startOf=function(f,m){var p=this,_=!!S.u(m)||m,b=S.p(f),E=function(K,D){var U=S.w(p.$u?Date.UTC(p.$y,D,K):new Date(p.$y,D,K),p);return _?U:U.endOf(h)},L=function(K,D){return S.w(p.toDate()[K].apply(p.toDate("s"),(_?[0,0,0,0]:[23,59,59,999]).slice(D)),p)},k=this.$W,F=this.$M,B=this.$D,st="set"+(this.$u?"UTC":"");switch(b){case x:return _?E(1,0):E(31,11);case u:return _?E(1,F):E(0,F+1);case l:var W=this.$locale().weekStart||0,gt=(k<W?k+7:k)-W;return E(_?B-gt:B+(6-gt),F);case h:case w:return L(st+"Hours",0);case c:return L(st+"Minutes",1);case o:return L(st+"Seconds",2);case a:return L(st+"Milliseconds",3);default:return this.clone()}},d.endOf=function(f){return this.startOf(f,!1)},d.$set=function(f,m){var p,_=S.p(f),b="set"+(this.$u?"UTC":""),E=(p={},p[h]=b+"Date",p[w]=b+"Date",p[u]=b+"Month",p[x]=b+"FullYear",p[c]=b+"Hours",p[o]=b+"Minutes",p[a]=b+"Seconds",p[r]=b+"Milliseconds",p)[_],L=_===h?this.$D+(m-this.$W):m;if(_===u||_===x){var k=this.clone().set(w,1);k.$d[E](L),k.init(),this.$d=k.set(w,Math.min(this.$D,k.daysInMonth())).$d}else E&&this.$d[E](L);return this.init(),this},d.set=function(f,m){return this.clone().$set(f,m)},d.get=function(f){return this[S.p(f)]()},d.add=function(f,m){var p,_=this;f=Number(f);var b=S.p(m),E=function(F){var B=P(_);return S.w(B.date(B.date()+Math.round(F*f)),_)};if(b===u)return this.set(u,this.$M+f);if(b===x)return this.set(x,this.$y+f);if(b===h)return E(1);if(b===l)return E(7);var L=(p={},p[o]=i,p[c]=s,p[a]=n,p)[b]||1,k=this.$d.getTime()+f*L;return S.w(k,this)},d.subtract=function(f,m){return this.add(-1*f,m)},d.format=function(f){var m=this,p=this.$locale();if(!this.isValid())return p.invalidDate||$;var _=f||"YYYY-MM-DDTHH:mm:ssZ",b=S.z(this),E=this.$H,L=this.$m,k=this.$M,F=p.weekdays,B=p.months,st=p.meridiem,W=function(D,U,yt,Pt){return D&&(D[U]||D(m,_))||yt[U].slice(0,Pt)},gt=function(D){return S.s(E%12||12,D,"0")},K=st||function(D,U,yt){var Pt=D<12?"AM":"PM";return yt?Pt.toLowerCase():Pt};return _.replace(O,(function(D,U){return U||(function(yt){switch(yt){case"YY":return String(m.$y).slice(-2);case"YYYY":return S.s(m.$y,4,"0");case"M":return k+1;case"MM":return S.s(k+1,2,"0");case"MMM":return W(p.monthsShort,k,B,3);case"MMMM":return W(B,k);case"D":return m.$D;case"DD":return S.s(m.$D,2,"0");case"d":return String(m.$W);case"dd":return W(p.weekdaysMin,m.$W,F,2);case"ddd":return W(p.weekdaysShort,m.$W,F,3);case"dddd":return F[m.$W];case"H":return String(E);case"HH":return S.s(E,2,"0");case"h":return gt(1);case"hh":return gt(2);case"a":return K(E,L,!0);case"A":return K(E,L,!1);case"m":return String(L);case"mm":return S.s(L,2,"0");case"s":return String(m.$s);case"ss":return S.s(m.$s,2,"0");case"SSS":return S.s(m.$ms,3,"0");case"Z":return b}return null})(D)||b.replace(":","")}))},d.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},d.diff=function(f,m,p){var _,b=this,E=S.p(m),L=P(f),k=(L.utcOffset()-this.utcOffset())*i,F=this-L,B=function(){return S.m(b,L)};switch(E){case x:_=B()/12;break;case u:_=B();break;case g:_=B()/3;break;case l:_=(F-k)/6048e5;break;case h:_=(F-k)/864e5;break;case c:_=F/s;break;case o:_=F/i;break;case a:_=F/n;break;default:_=F}return p?_:S.a(_)},d.daysInMonth=function(){return this.endOf(u).$D},d.$locale=function(){return G[this.$L]},d.locale=function(f,m){if(!f)return this.$L;var p=this.clone(),_=Ot(f,m,!0);return _&&(p.$L=_),p},d.clone=function(){return S.w(this.$d,this)},d.toDate=function(){return new Date(this.valueOf())},d.toJSON=function(){return this.isValid()?this.toISOString():null},d.toISOString=function(){return this.$d.toISOString()},d.toString=function(){return this.$d.toUTCString()},v})(),Ce=At.prototype;return P.prototype=Ce,[["$ms",r],["$s",a],["$m",o],["$H",c],["$W",h],["$M",u],["$y",x],["$D",w]].forEach((function(v){Ce[v[1]]=function(d){return this.$g(d,v[0],v[1])}})),P.extend=function(v,d){return v.$i||(v(d,At,P),v.$i=!0),P},P.locale=Ot,P.isDayjs=Kt,P.unix=function(v){return P(1e3*v)},P.en=G[A],P.Ls=G,P.p={},P}))})($t)),$t.exports}var Ki=Wi();const Vi=le(Ki);class Wt extends It{SOURCE=mt;static NAME=X;constructor(t,n){super(t,n),this.options.tooltip&&(this.setTooltip(new Ae(this.context.map,{id:this.id,position:this.position(),className:"mapbox-gl-ship-name-tooltip",offsetX:5,offsetY:25,element:this.label(),anchor:"bottom-right",visible:!0})),this.render())}onAdd(){this.context.register.addSource(mt,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),Ui.forEach(t=>{this.context.register.addLayer(t)})}onRemove(){throw new Error("Method not implemented.")}get id(){return this.options.id}get updateStatus(){const t=Date.now()-Vi(Number(this.options.time)).valueOf();return t<=18e5?z.ONLINE:t>18e5&&t<=72e5?z.DELAY:(t>72e5,z.OFFLINE)}getIconName(){const t=this.getState();let n=null;return this.options.icon?n=this.options.icon:(n=`${Wt.NAME}-${this.updateStatus}-${this.orientation}`,(t?.hover||t?.focus)&&(n=`${n}-active`)),n}position(){const t=this.context.map.project(this.options.position),n=t.x+this.offset().x,i=t.y+this.offset().y;return this.context.map.unproject(new I.Point(n,i))}get direction(){return this.options.hdg&&this.options.hdg>=0&&this.options.hdg<360?this.options.statusId===0||this.options.statusId===7||this.options.statusId===8?this.options.speed<=.5?this.options.hdg||this.options.cog||0:Math.abs(this.options.hdg-this.options.cog)>30?this.options.cog:this.options.cog||this.options.hdg||0:this.options.hdg||this.options.cog||0:this.options.cog||0}get orientation(){let t=0;return this.options.rot>180&&(t=this.options.rot-180),this.options.rot<-180&&(t=this.options.rot+180),this.options.speed===0||!this.options.speed||t===-128?"static":t<0&&t>-180?"left":t>0&&t<=180?"right":t===0?"straight":"static"}getShape(){if(this.options.width&&this.options.height){const{x:t,y:n}=this.context.map.project(this.position()),i=ut(this.context.map,this.options.width)/2,s=ut(this.context.map,this.options.height)/2;return{leftDirection:new I.Point(t-i,n-s*2),rightDirection:new I.Point(t+i,n-s*2),turn:new I.Point(t,n-s*2),head:new I.Point(t,n-s),rightBow:new I.Point(t+i,n-s*.5),rightQuarter:new I.Point(t+i,n+s*.85),rightStern:new I.Point(t+i*.7,n+s),leftStern:new I.Point(t-i*.7,n+s),leftQuarter:new I.Point(t-i,n+s*.85),leftBow:new I.Point(t-i,n-s*.5)}}else return null}getFeature(){const t=this.options.realZoom??16;return this.context.map.getZoom()>=t?this.real():this.icon()}remove(){this.tooltip?.remove();const t={type:"Feature",geometry:null,id:this.id,properties:{}};this.context.register.updateGeoJSONData(this.SOURCE,t)}setTooltip(t){this.tooltip=t}update(t){this.options=t,this.render()}select(){this.context.map.flyTo({center:this.position(),zoom:16}),this.context.map.once("moveend",()=>{this.focus()})}unselect(){this.unfocus()}focus(){this.setState({focus:!0}),this.render()}unfocus(){this.setState({focus:!1}),this.render()}icon(){return Ft(this.position().toArray(),{...this.options,icon:this.getIconName(),direction:this.direction,updateStatus:this.updateStatus},{id:this.id})}real(){const t=this.getShape();if(t){const{head:n,rightBow:i,rightQuarter:s,rightStern:r,leftStern:a,leftQuarter:o,leftBow:c,leftDirection:h,rightDirection:l,turn:u}=t;let g=[n,i,s,r,a,o,c,n];this.orientation==="left"?g=[h,u,...g,u,h]:this.orientation==="right"?g=[l,u,...g,u,l]:this.orientation==="straight"&&(g=[u,...g,u]);const x=Yt(g.map($=>this.context.map.unproject($).toArray()));let w=rn(x,{properties:{...this.options,updateStatus:this.updateStatus,outLine:!0}});return w=sn(w,this.direction,{pivot:this.position().toArray()}),w.id=this.id,w}else return this.icon()}render(){if(this.tooltip?.setLngLat(this.position()),this.tooltip?.render(),this.context.register.updateGeoJSONData(this.SOURCE,this.getFeature()),this.isFocus){const t=this.context.iconManage.getImage(this.getIconName());this.context.focus.set(this.getFeature(),{size:t?.width,armLength:10,padding:10})}}label(){const t=`${String(this.id)}-ship-name-box`;let n=document.getElementById(t);if(n)return n;n=document.createElement("div"),n.id=t,n.classList.add("ship-name-box");const i=document.createElement("div");return i.innerText=this.options.name,i.classList.add("ship-name"),n.appendChild(i),n}offset(){const t=new I.Point(0,0);if(this.options.top&&this.options.bottom&&this.options.left&&this.options.right){const n=ut(this.context.map,Math.abs(this.options.top-this.options.bottom)/2),i=ut(this.context.map,Math.abs(this.options.left-this.options.right)/2);t.x=this.options.right>this.options.left?i:-i,t.y=this.options.top>this.options.bottom?n:-n}return t}}C.AisShip=Wt,C.BaseShip=It,C.CMap=qi,C.Cache=Vt,C.Collision=ne,C.CollisionItem=ee,C.Context=Oe,C.IconManager=tt,C.Module=dt,C.Ship=Ji,C.Tooltip=Ae,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
|
|
75
|
+
</svg>`}],qs=Object.freeze(Object.defineProperty({__proto__:null,LAYER_LIST:wi,MAX_ICON_SIZE:Hs,MIN_ICON_SIZE:Us,NAME:j,SHIP_COLOR:Tt,SHIP_ICON:_i,SHIP_ICON_LAYER:yi,SHIP_ICON_LAYER_NAME:Z,SHIP_REAL_LAYER:vi,SHIP_REAL_LAYER_NAME:G,SHIP_REAL_OUTLINE_LAYER:xi,SHIP_REAL_OUTLINE_LAYER_NAME:gi,SHIP_SOURCE_NAME:gt,UPDATE_STATUS:H},Symbol.toStringTag,{value:"Module"}));var me=(e=>(e.LAND="land",e.SATELLITE="satellite",e.CUSTOM="custom",e))(me||{});const bi={version:8,name:"Basic",glyphs:"https://sdkinteligenceberth.zhonganhse.com:21333/app/font/{fontstack}/{range}.pbf",sources:{base:{tiles:["http://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t1.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t2.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t3.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t4.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t5.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t6.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t7.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990"],type:"raster",tileSize:256,minzoom:0,maxzoom:21},label:{tiles:["http://t0.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t1.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t2.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t3.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t4.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t5.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t6.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t7.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990"],type:"raster",tileSize:256,minzoom:0,maxzoom:21}},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(212,234,238,1)"}},{id:"base_layer",source:"base",type:"raster"},{id:"label_layer",source:"label",type:"raster"},{id:"base-end",type:"background",paint:{"background-color":"transparent"}},{id:"point-end",type:"background",paint:{"background-color":"transparent"}}]},Si={version:8,name:"Basic",glyphs:"https://sdkinteligenceberth.zhonganhse.com:21333/app/font/{fontstack}/{range}.pbf",sources:{base:{tiles:["http://t0.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t1.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t2.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t3.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t4.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t5.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t6.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t7.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990"],type:"raster",tileSize:256,minzoom:0,maxzoom:21},label:{tiles:["http://t0.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t1.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t2.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t3.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t4.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t5.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t6.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990","http://t7.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=15999a02266fd7d952a7a771eca68990"],type:"raster",tileSize:256,minzoom:0,maxzoom:21}},layers:[{id:"background",type:"background",paint:{"background-color":"rgba(212,234,238,1)"}},{id:"base_layer",source:"base",type:"raster"},{id:"label_layer",source:"label",type:"raster"},{id:"base-end",type:"background",paint:{"background-color":"transparent"}},{id:"point-end",type:"background",paint:{"background-color":"transparent"}}]};class yt extends ne{map;options;cache=new Set;timer=null;originalRemove;icon;static LAND=me.LAND;static SATELLITE=me.SATELLITE;constructor(t){super(),this.options=t,t.type===yt.LAND?this.options.style=bi:t.type===yt.SATELLITE&&(this.options.style=Si),A.Map.prototype._authenticate=()=>{},this.map=new A.Map(this.options),this.icon=new ut(this.map),this.originalRemove=this.map.remove.bind(this.map),this.map.remove=()=>{let i=!1;this.map.fire("beforeRemove",{cancel:()=>{i=!0},next:()=>{i=!1}}),i||this.originalRemove()},this.map.once("load",()=>{_i.forEach(async i=>{await Promise.all([this.icon.addSvg({name:i.name.replace("$color",H.ONLINE),svg:i.svg.replace("$color",Tt.ONLINE)}),this.icon.addSvg({name:i.name.replace("$color",H.DELAY),svg:i.svg.replace("$color",Tt.DELAY)}),this.icon.addSvg({name:i.name.replace("$color",H.OFFLINE),svg:i.svg.replace("$color",Tt.OFFLINE)})])}),this.emit("loaded",this.map)})}change(t){t===yt.LAND?this.getMap().setStyle(bi):t===yt.SATELLITE&&this.getMap().setStyle(Si)}getMap(){return this.map}zoomIn(){this.getMap().isZooming()||this.getMap().zoomIn()}zoomOut(){this.getMap().isZooming()||this.getMap().zoomOut()}mapLoaded(){const t=i=>{this.getMap()._loaded?(this.timer&&(clearInterval(this.timer),this.timer=null),this.cache.size>0&&(this.cache.forEach(n=>{n(this.getMap())}),this.cache.clear()),i(this.getMap())):this.timer?this.cache.add(i):this.timer=setInterval(()=>{t(i)},16)};return new Promise((i,n)=>{try{t(i)}catch(r){this.timer&&(clearInterval(this.timer),this.timer=null),n(new Error(`mapLoaded错误:${r}`))}})}}var Ut=(e=>(e.ON="On",e.OFF="Off",e))(Ut||{});class nt extends mt{status=Ut.OFF;static ON=Ut.ON;static OFF=Ut.OFF;constructor(t){super(t)}switch(){return this.status===nt.ON?(this.status=nt.OFF,this.off()):this.status===nt.OFF&&(this.status=nt.ON,this.on()),this.status}}class Zs extends nt{ships=[];hoverId=null;_click=()=>{};_move=()=>{};_leave=()=>{};_zoomEnd=()=>{};constructor(t,i){super(t),i&&(this.ships=i)}on(){this.context.map.on("click",Z,this._click),this.context.map.on("mousemove",Z,this._move),this.context.map.on("mouseleave",Z,this._leave),this.context.map.on("click",G,this._click),this.context.map.on("mousemove",G,this._move),this.context.map.on("mouseleave",G,this._leave),this.context.map.on("zoomend",this._zoomEnd)}off(){this.context.map.off("click",Z,this._click),this.context.map.off("mousemove",Z,this._move),this.context.map.off("mouseleave",Z,this._leave),this.context.map.off("click",G,this._click),this.context.map.off("mousemove",G,this._move),this.context.map.off("mouseleave",G,this._leave),this.context.map.off("zoomend",this._zoomEnd)}onAdd(){this._click=this.onClick.bind(this),this._move=this.onMove.bind(this),this._leave=this.onLeave.bind(this),this._zoomEnd=this.onZoomEnd.bind(this),this.on()}onRemove(){this.off()}add(t){const i=this.findShip(t.id);i?t.update(i.options):this.ships.push(t)}remove(t){const i=this.ships.findIndex(n=>n.id===t);i!==-1&&this.ships.splice(i,1)}removeAll(){this.ships=[]}onZoomEnd(){this.ships.forEach(t=>{t.render()})}onMove(t){if(t.features?.length){if(this.context.map.getCanvasContainer().style.cursor="pointer",this.hoverId===t.features[0].id)return;this.hoverId&&this.unhover(),this.hoverId=t.features[0].id,this.hover()}}onLeave(){this.unhover(),this.hoverId=null,this.context.map.getCanvasContainer().style.cursor=""}onClick(t){if(t.features?.length){const i=t.features[0].id;if(i){const n=this.findShip(i);this.context.events.emit("click",n),this.context.map.fire("ship-click",n)}}}hover(){if(!this.hoverId)return;const t=this.findShip(this.hoverId);t?.setState({hover:!0}),t?.render(),this.context.events.emit("hover",t),this.context.map.fire("ship-hover",t)}unhover(){if(!this.hoverId)return;const t=this.findShip(this.hoverId);t?.setState({hover:!1}),t?.render(),this.context.events.emit("unhover",t),this.context.map.fire("ship-unhover",t)}findShip(t){return this.ships.find(i=>String(i.id)===String(t))}}class Gs extends mt{options;ships=[];event;pluginRegistry=new Map;collision;focusId=null;constructor(t,i){super(t),this.options=i,this.collision=new Vt(this.context.map),this.event=new Zs(t),this.registerPlugins(i.plugins)}onAdd(){}onRemove(){}get tooltips(){return this.ships.flatMap(t=>t.tooltip??[])}registerPlugins(t=[]){t.forEach(i=>{i.NAME?this.pluginRegistry.set(i.NAME,i):console.warn("Ship Plugin missing static NAME property:",i)})}createCollisions(){return this.tooltips.map(t=>({...t.getSimpleBbox(),id:t.id}))}collisionTooltip(){this.collision.load(this.createCollisions()).forEach(t=>{const i=this.tooltips.find(n=>n.id===t.id);i&&t.visible&&i.setAnchor(t.dir)})}add(t){const i=this.pluginRegistry.get(t.type);if(!i){console.warn(`No plugin registered for ship type: "${t.type}"`);return}const n=new i(this.context.map,t);return this.ships.push(n),this.event.add(n),n}load(t){this.removeAll();const i=[];if(t.forEach(n=>{const r=this.add(n);r&&i.push(r)}),this.render(),this.collisionTooltip(),this.focusId){const n=this.get(this.focusId);n&&n.focus()}return i}remove(t){this.event.remove(t);const i=this.ships.findIndex(n=>n.id===t);i!==-1&&(this.ships[i].remove(),this.ships.splice(i,1))}removeAll(){this.collision.clear(),this.ships.forEach(t=>{t.remove()}),this.ships=[],this.event.removeAll()}render(){this.ships.forEach(t=>{t.render()})}get(t){return this.ships.find(i=>i.id===t)}select(t){const i=this.get(t);i?(i.select(),this.focusId=i.id):console.warn(`The ship-${String(t)} was not found.`)}unselect(t){const i=this.get(t);i?(i.unselect(),this.focusId=null):console.warn(`The ship-${String(t)} was not found.`)}}class Ht extends mt{options;SOURCE="mapbox-gl-ship-source";static NAME="Base";tooltip=null;visible=!0;constructor(t,i){super(t),this.options=i}destroy(){throw new Error("Method not implemented.")}get isFocus(){const t=this.getState();return t?!!t.focus:!1}setState(t){this.context.map.setFeatureState({source:this.SOURCE,id:this.id},t)}getState(){return this.context.map.getFeatureState({source:this.SOURCE,id:this.id})}isSelf(t){if(t.features&&t.features.length>0){const i=t.features[0];return String(i.id)===this.id}else return!1}getName(){return Ht.NAME}}var qt={exports:{}},Js=qt.exports,Mi;function Ks(){return Mi||(Mi=1,(function(e,t){(function(i,n){e.exports=n()})(Js,(function(){var i=1e3,n=6e4,r=36e5,s="millisecond",o="second",a="minute",h="hour",c="day",l="week",u="month",m="quarter",y="year",w="date",T="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,O=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,B={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(x){var p=["th","st","nd","rd"],f=x%100;return"["+x+(p[(f-20)%10]||p[f]||p[0])+"]"}},S=function(x,p,f){var g=String(x);return!g||g.length>=p?x:""+Array(p+1-g.length).join(f)+x},Y={s:S,z:function(x){var p=-x.utcOffset(),f=Math.abs(p),g=Math.floor(f/60),d=f%60;return(p<=0?"+":"-")+S(g,2,"0")+":"+S(d,2,"0")},m:function x(p,f){if(p.date()<f.date())return-x(f,p);var g=12*(f.year()-p.year())+(f.month()-p.month()),d=p.clone().add(g,u),_=f-d<0,b=p.clone().add(g+(_?-1:1),u);return+(-(g+(f-d)/(_?d-b:b-d))||0)},a:function(x){return x<0?Math.ceil(x)||0:Math.floor(x)},p:function(x){return{M:u,y,w:l,d:c,D:w,h,m:a,s:o,ms:s,Q:m}[x]||String(x||"").toLowerCase().replace(/s$/,"")},u:function(x){return x===void 0}},k="en",ot={};ot[k]=B;var Pi="$isDayjsObject",_e=function(x){return x instanceof Gt||!(!x||!x[Pi])},Zt=function x(p,f,g){var d;if(!p)return k;if(typeof p=="string"){var _=p.toLowerCase();ot[_]&&(d=_),f&&(ot[_]=f,d=_);var b=p.split("-");if(!d&&b.length>1)return x(b[0])}else{var L=p.name;ot[L]=p,d=L}return!g&&d&&(k=d),d||!g&&k},N=function(x,p){if(_e(x))return x.clone();var f=typeof p=="object"?p:{};return f.date=x,f.args=arguments,new Gt(f)},E=Y;E.l=Zt,E.i=_e,E.w=function(x,p){return N(x,{locale:p.$L,utc:p.$u,x:p.$x,$offset:p.$offset})};var Gt=(function(){function x(f){this.$L=Zt(f.locale,null,!0),this.parse(f),this.$x=this.$x||f.x||{},this[Pi]=!0}var p=x.prototype;return p.parse=function(f){this.$d=(function(g){var d=g.date,_=g.utc;if(d===null)return new Date(NaN);if(E.u(d))return new Date;if(d instanceof Date)return new Date(d);if(typeof d=="string"&&!/Z$/i.test(d)){var b=d.match(v);if(b){var L=b[2]-1||0,I=(b[7]||"0").substring(0,3);return _?new Date(Date.UTC(b[1],L,b[3]||1,b[4]||0,b[5]||0,b[6]||0,I)):new Date(b[1],L,b[3]||1,b[4]||0,b[5]||0,b[6]||0,I)}}return new Date(d)})(f),this.init()},p.init=function(){var f=this.$d;this.$y=f.getFullYear(),this.$M=f.getMonth(),this.$D=f.getDate(),this.$W=f.getDay(),this.$H=f.getHours(),this.$m=f.getMinutes(),this.$s=f.getSeconds(),this.$ms=f.getMilliseconds()},p.$utils=function(){return E},p.isValid=function(){return this.$d.toString()!==T},p.isSame=function(f,g){var d=N(f);return this.startOf(g)<=d&&d<=this.endOf(g)},p.isAfter=function(f,g){return N(f)<this.startOf(g)},p.isBefore=function(f,g){return this.endOf(g)<N(f)},p.$g=function(f,g,d){return E.u(f)?this[g]:this.set(d,f)},p.unix=function(){return Math.floor(this.valueOf()/1e3)},p.valueOf=function(){return this.$d.getTime()},p.startOf=function(f,g){var d=this,_=!!E.u(g)||g,b=E.p(f),L=function(ct,F){var K=E.w(d.$u?Date.UTC(d.$y,F,ct):new Date(d.$y,F,ct),d);return _?K:K.endOf(c)},I=function(ct,F){return E.w(d.toDate()[ct].apply(d.toDate("s"),(_?[0,0,0,0]:[23,59,59,999]).slice(F)),d)},$=this.$W,P=this.$M,z=this.$D,vt="set"+(this.$u?"UTC":"");switch(b){case y:return _?L(1,0):L(31,11);case u:return _?L(1,P):L(0,P+1);case l:var at=this.$locale().weekStart||0,Ot=($<at?$+7:$)-at;return L(_?z-Ot:z+(6-Ot),P);case c:case w:return I(vt+"Hours",0);case h:return I(vt+"Minutes",1);case a:return I(vt+"Seconds",2);case o:return I(vt+"Milliseconds",3);default:return this.clone()}},p.endOf=function(f){return this.startOf(f,!1)},p.$set=function(f,g){var d,_=E.p(f),b="set"+(this.$u?"UTC":""),L=(d={},d[c]=b+"Date",d[w]=b+"Date",d[u]=b+"Month",d[y]=b+"FullYear",d[h]=b+"Hours",d[a]=b+"Minutes",d[o]=b+"Seconds",d[s]=b+"Milliseconds",d)[_],I=_===c?this.$D+(g-this.$W):g;if(_===u||_===y){var $=this.clone().set(w,1);$.$d[L](I),$.init(),this.$d=$.set(w,Math.min(this.$D,$.daysInMonth())).$d}else L&&this.$d[L](I);return this.init(),this},p.set=function(f,g){return this.clone().$set(f,g)},p.get=function(f){return this[E.p(f)]()},p.add=function(f,g){var d,_=this;f=Number(f);var b=E.p(g),L=function(P){var z=N(_);return E.w(z.date(z.date()+Math.round(P*f)),_)};if(b===u)return this.set(u,this.$M+f);if(b===y)return this.set(y,this.$y+f);if(b===c)return L(1);if(b===l)return L(7);var I=(d={},d[a]=n,d[h]=r,d[o]=i,d)[b]||1,$=this.$d.getTime()+f*I;return E.w($,this)},p.subtract=function(f,g){return this.add(-1*f,g)},p.format=function(f){var g=this,d=this.$locale();if(!this.isValid())return d.invalidDate||T;var _=f||"YYYY-MM-DDTHH:mm:ssZ",b=E.z(this),L=this.$H,I=this.$m,$=this.$M,P=d.weekdays,z=d.months,vt=d.meridiem,at=function(F,K,kt,Jt){return F&&(F[K]||F(g,_))||kt[K].slice(0,Jt)},Ot=function(F){return E.s(L%12||12,F,"0")},ct=vt||function(F,K,kt){var Jt=F<12?"AM":"PM";return kt?Jt.toLowerCase():Jt};return _.replace(O,(function(F,K){return K||(function(kt){switch(kt){case"YY":return String(g.$y).slice(-2);case"YYYY":return E.s(g.$y,4,"0");case"M":return $+1;case"MM":return E.s($+1,2,"0");case"MMM":return at(d.monthsShort,$,z,3);case"MMMM":return at(z,$);case"D":return g.$D;case"DD":return E.s(g.$D,2,"0");case"d":return String(g.$W);case"dd":return at(d.weekdaysMin,g.$W,P,2);case"ddd":return at(d.weekdaysShort,g.$W,P,3);case"dddd":return P[g.$W];case"H":return String(L);case"HH":return E.s(L,2,"0");case"h":return Ot(1);case"hh":return Ot(2);case"a":return ct(L,I,!0);case"A":return ct(L,I,!1);case"m":return String(I);case"mm":return E.s(I,2,"0");case"s":return String(g.$s);case"ss":return E.s(g.$s,2,"0");case"SSS":return E.s(g.$ms,3,"0");case"Z":return b}return null})(F)||b.replace(":","")}))},p.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},p.diff=function(f,g,d){var _,b=this,L=E.p(g),I=N(f),$=(I.utcOffset()-this.utcOffset())*n,P=this-I,z=function(){return E.m(b,I)};switch(L){case y:_=z()/12;break;case u:_=z();break;case m:_=z()/3;break;case l:_=(P-$)/6048e5;break;case c:_=(P-$)/864e5;break;case h:_=P/r;break;case a:_=P/n;break;case o:_=P/i;break;default:_=P}return d?_:E.a(_)},p.daysInMonth=function(){return this.endOf(u).$D},p.$locale=function(){return ot[this.$L]},p.locale=function(f,g){if(!f)return this.$L;var d=this.clone(),_=Zt(f,g,!0);return _&&(d.$L=_),d},p.clone=function(){return E.w(this.$d,this)},p.toDate=function(){return new Date(this.valueOf())},p.toJSON=function(){return this.isValid()?this.toISOString():null},p.toISOString=function(){return this.$d.toISOString()},p.toString=function(){return this.$d.toUTCString()},x})(),Ri=Gt.prototype;return N.prototype=Ri,[["$ms",s],["$s",o],["$m",a],["$H",h],["$W",c],["$M",u],["$y",y],["$D",w]].forEach((function(x){Ri[x[1]]=function(p){return this.$g(p,x[0],x[1])}})),N.extend=function(x,p){return x.$i||(x(p,Gt,N),x.$i=!0),N},N.locale=Zt,N.isDayjs=_e,N.unix=function(x){return N(1e3*x)},N.en=ot[k],N.Ls=ot,N.p={},N}))})(qt)),qt.exports}var Ws=Ks();const Ei=Ne(Ws);class ge extends Ht{SOURCE=gt;static NAME=j;constructor(t,i){super(t,i),this.options.tooltip&&this.setTooltip(new It(this.context.map,{id:this.id,position:this.position(),className:"mapbox-gl-ship-name-tooltip",offsetX:5,offsetY:25,element:this.label(),anchor:"bottom-right",visible:!1}))}onAdd(){this.context.register.addSource(gt,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),wi.forEach(t=>{this.context.register.addLayer(t)})}onRemove(){throw new Error("Method not implemented.")}get id(){return this.options.id}get updateStatus(){const t=Date.now()-Ei(Number(this.options.time)).valueOf();return t<=18e5?H.ONLINE:t>18e5&&t<=72e5?H.DELAY:(t>72e5,H.OFFLINE)}getIconName(){const t=this.getState();let i=null;return this.options.icon?i=this.options.icon:(i=`${ge.NAME}-${this.updateStatus}-${this.orientation}`,(t?.hover||t?.focus)&&(i=`${i}-active`)),i}position(){const t=this.context.map.project(this.options.position),i=t.x+this.offset().x,n=t.y+this.offset().y;return this.context.map.unproject(new A.Point(i,n))}get direction(){return this.options.hdg&&this.options.hdg>=0&&this.options.hdg<360?this.options.statusId===0||this.options.statusId===7||this.options.statusId===8?this.options.speed<=.5?this.options.hdg||this.options.cog||0:Math.abs(this.options.hdg-this.options.cog)>30?this.options.cog:this.options.cog||this.options.hdg||0:this.options.hdg||this.options.cog||0:this.options.cog||0}get orientation(){let t=0;return this.options.rot>180&&(t=this.options.rot-180),this.options.rot<-180&&(t=this.options.rot+180),this.options.speed===0||!this.options.speed||t===-128?"static":t<0&&t>-180?"left":t>0&&t<=180?"right":t===0?"straight":"static"}getShape(){if(this.options.width&&this.options.height){const{x:t,y:i}=this.context.map.project(this.position()),n=Et(this.context.map,this.options.width)/2,r=Et(this.context.map,this.options.height)/2;return{leftDirection:new A.Point(t-n,i-r*2),rightDirection:new A.Point(t+n,i-r*2),turn:new A.Point(t,i-r*2),head:new A.Point(t,i-r),rightBow:new A.Point(t+n,i-r*.5),rightQuarter:new A.Point(t+n,i+r*.85),rightStern:new A.Point(t+n*.7,i+r),leftStern:new A.Point(t-n*.7,i+r),leftQuarter:new A.Point(t-n,i+r*.85),leftBow:new A.Point(t-n,i-r*.5)}}else return null}getFeature(){const t=this.options.realZoom??16;return this.context.map.getZoom()>=t?this.real():this.icon()}remove(){this.removeTooltip(),this.isFocus&&(this.unfocus(),this.context.focus.remove(String(this.id)));const t={type:"Feature",geometry:null,id:this.id,properties:{}};this.context.register.setGeoJSONData(this.SOURCE,t),this.context.map.triggerRepaint()}setTooltip(t){this.tooltip=t}removeTooltip(){this.tooltip?.remove(),this.tooltip=null}update(t){this.options=t,this.render()}select(){this.context.map.flyTo({center:this.position(),zoom:16}),this.context.map.once("moveend",()=>{this.focus()})}unselect(){this.unfocus()}focus(){this.setState({focus:!0}),this.render()}unfocus(){this.setState({focus:!1}),this.render()}icon(){return Dt(this.position().toArray(),{...this.options,icon:this.getIconName(),direction:this.direction,updateStatus:this.updateStatus},{id:this.id})}real(){const t=this.getShape();if(t){const{head:i,rightBow:n,rightQuarter:r,rightStern:s,leftStern:o,leftQuarter:a,leftBow:h,leftDirection:c,rightDirection:l,turn:u}=t;let m=[i,n,r,s,o,a,h,i];this.orientation==="left"?m=[c,u,...m,u,c]:this.orientation==="right"?m=[l,u,...m,u,l]:this.orientation==="straight"&&(m=[u,...m,u]);const y=Pt(m.map(T=>this.context.map.unproject(T).toArray()));let w=ln(y,{properties:{...this.options,updateStatus:this.updateStatus,outLine:!0}});return w=hn(w,this.direction,{pivot:this.position().toArray()}),w.id=this.id,w}else return this.icon()}render(){if(!this.context.map.getBounds()?.contains(this.position())){this.tooltip?.hide();return}if(this.tooltip?.render(),this.context.register.setGeoJSONData(this.SOURCE,this.getFeature()),this.isFocus){const i=this.context.iconManage.getImage(this.getIconName());this.context.focus.set(this.getFeature(),{size:i?.width,armLength:10,padding:10})}else this.context.focus.remove(String(this.id))}label(){const t=`${String(this.id)}-ship-name-box`;let i=document.getElementById(t);if(i)return i;i=document.createElement("div"),i.id=t,i.classList.add("ship-name-box");const n=document.createElement("div");return n.innerText=this.options.name,n.classList.add("ship-name"),i.appendChild(n),i}offset(){const t=new A.Point(0,0);if(this.options.top&&this.options.bottom&&this.options.left&&this.options.right){const i=Et(this.context.map,Math.abs(this.options.top-this.options.bottom)/2),n=Et(this.context.map,Math.abs(this.options.left-this.options.right)/2);t.x=this.options.right>this.options.left?n:-n,t.y=this.options.top>this.options.bottom?i:-i}return t}}var J=(e=>(e[e.START_END=0]="START_END",e[e.SHARP_TURN=1]="SHARP_TURN",e[e.STOP_GO=2]="STOP_GO",e[e.TIME_ANCHOR=3]="TIME_ANCHOR",e[e.NORMAL=9]="NORMAL",e))(J||{});const Vs="Track",rt="mapbox-gl-track-source",Li="mapbox-gl-track-arrow-layer",st="mapbox-gl-track-icon-layer",Ci="mapbox-gl-track-line-layer",ye="track-start",Ai='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="74" height="74" viewBox="0 0 74 74" fill="none"><circle cx="37" cy="37" r="32" stroke="rgba(172, 51, 193, 1)" stroke-width="10" fill="#AC33C1" ></circle><path d="M36.4 50.84C40.84 51.08 45.24 51.08 45.24 51.08C50.52 51.08 55.12 50.8 55.12 50.8L54.48 54.36C50.16 54.64 45.24 54.64 45.24 54.64C40.32 54.64 35.96 54.36 35.96 54.36C31.16 54.08 28.16 52.72 28.16 52.72C25.16 51.36 23.4 48.36 23.4 48.36C22.64 51.96 20.84 55.72 20.84 55.72L18 53.52C19.16 51.04 19.76 48.94 19.76 48.94C20.36 46.84 20.62 44.26 20.62 44.26C20.88 41.68 20.88 37.64 20.88 37.64L24.2 37.64C24.2 40.92 24.04 43.12 24.04 43.12C25.16 46.52 27.28 48.24 27.28 48.24L27.28 35.44L18.68 35.44L18.68 32.08L26.32 32.08L26.32 27.12L20.08 27.12L20.08 23.72L26.32 23.72L26.32 19L29.84 19L29.84 23.72L35.64 23.72L35.64 27.12L29.84 27.12L29.84 32.08L36.76 32.08L36.76 35.44L30.72 35.44L30.72 40.96L36.36 40.96L36.36 44.32L30.72 44.32L30.72 49.96C33 50.64 36.4 50.84 36.4 50.84ZM48.96 30.88L48.96 24.64L37.8 24.64L37.8 21.12L52.44 21.12L52.44 34.4L41.84 34.4L41.84 41.52C41.84 42.72 42.02 43.24 42.02 43.24C42.2 43.76 42.68 43.98 42.68 43.98C43.16 44.2 44.28 44.32 44.28 44.32C44.88 44.36 46 44.36 46 44.36C47.12 44.36 47.72 44.32 47.72 44.32C48.88 44.2 49.44 43.98 49.44 43.98C50 43.76 50.22 43.28 50.22 43.28C50.44 42.8 50.52 41.8 50.52 41.8C50.68 39.72 50.68 38.44 50.68 38.44L54.08 39.24C53.96 41.12 53.8 43 53.8 43C53.6 45.04 53.16 45.98 53.16 45.98C52.72 46.92 51.72 47.3 51.72 47.3C50.72 47.68 48.64 47.8 48.64 47.8C46.8 47.88 45.88 47.88 45.88 47.88C44.96 47.88 43.12 47.8 43.12 47.8C41.2 47.68 40.22 47.2 40.22 47.2C39.24 46.72 38.8 45.64 38.8 45.64C38.36 44.56 38.36 42.44 38.36 42.44L38.36 30.88L48.96 30.88Z" fill="#FFFFFF" ></path></svg>',ve="track-end",Ii='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="74" height="74" viewBox="0 0 74 74" fill="none"><circle cx="37" cy="37" r="32" stroke="rgba(172, 51, 193, 1)" stroke-width="10" fill="#AC33C1" ></circle><path d="M45.6 33.64C49.28 36.12 55.28 38.24 55.28 38.24L54 41.8C50.48 40.32 47.78 38.88 47.78 38.88C45.08 37.44 42.92 35.8 42.92 35.8C38.76 38.84 32.04 41.6 32.04 41.6L30.4 38.4C36.28 36.2 40.24 33.56 40.24 33.56C38.2 31.6 36.12 28.8 36.12 28.8C34.56 30.92 32.68 32.88 32.68 32.88L30.72 30.36C32.88 28.08 35.08 24.52 35.08 24.52C37.28 20.96 38.4 18 38.4 18L41.64 18.92C41.2 19.96 40.24 22.04 40.24 22.04L52.04 22.04L52.04 25.48C50.56 27.96 49.02 29.96 49.02 29.96C47.48 31.96 45.6 33.64 45.6 33.64ZM20.76 33.44C19.96 33.48 19 33.76 19 33.76L18.2 30.24C18.72 30.04 18.98 29.82 18.98 29.82C19.24 29.6 19.56 29.2 19.56 29.2C20.44 28 22.06 24.68 22.06 24.68C23.68 21.36 24.92 18.2 24.92 18.2L28.04 19.4C26.8 22.28 25.24 25.4 25.24 25.4C23.68 28.52 22.6 30.04 22.6 30.04C25.92 29.56 26.76 29.44 26.76 29.44C28.16 26.68 29.28 24.16 29.28 24.16L32.16 25.52C30.52 28.92 28.16 33.22 28.16 33.22C25.8 37.52 24.4 39.48 24.4 39.48L27.36 38.76L29.76 38.16L29.84 41.68C29.28 41.72 26.86 42.2 26.86 42.2C24.44 42.68 22.52 43.08 22.52 43.08C21.96 43.2 20.84 43.52 20.84 43.52L19.92 43.76L19.08 40.12C19.96 39.76 20.34 39.48 20.34 39.48C20.72 39.2 21.2 38.64 21.2 38.64C22.84 36.6 24.92 32.84 24.92 32.84C22.24 33.28 20.76 33.44 20.76 33.44ZM38.08 25.92C40.2 29.2 42.88 31.52 42.88 31.52C45.56 29.16 48.12 25.4 48.12 25.4L38.4 25.4L38.08 25.92ZM37.6 39.4L40.8 40.4L49.4 43.08L48.12 46.52C45.76 45.68 42.22 44.5 42.22 44.5C38.68 43.32 36.64 42.76 36.64 42.76L37.6 39.4ZM18 49.08C18.68 48.96 21.08 48.4 21.08 48.4C23.48 47.84 25.2 47.44 25.2 47.44C30.76 46.2 31.08 46.12 31.08 46.12L31.28 49.6C30.12 49.8 22.24 51.6 22.24 51.6C18.8 52.44 18.48 52.48 18.48 52.48L18 49.08ZM34.4 46.48C37.24 47.24 42.46 48.82 42.46 48.82C47.68 50.4 51.12 51.52 51.12 51.52L49.92 55.04C46.44 53.8 41.38 52.2 41.38 52.2C36.32 50.6 33.44 49.84 33.44 49.84L34.4 46.48Z" fill="#FFFFFF" ></path></svg>',xe="track-arrow",Ti='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="74" height="74" viewBox="0 0 74 74" fill="none"><circle cx="37" cy="37" r="32" stroke="rgba(172, 51, 193, 1)" stroke-width="10" fill="#FFFFFF" ></circle></svg>',we="track-normal",Oi='<svg t="1769503360247" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="24046" width="64" height="64"><path d="M509.093 894.223l-447.093-761.539 452.861 219.23099999 447.139-222.13799999z" p-id="24047" fill="#d81e06"></path></svg>',ki={id:Li,source:rt,type:"symbol",layout:{"symbol-placement":"line","symbol-spacing":250,"icon-image":xe,"icon-size":.3,"icon-rotate":-90,"icon-allow-overlap":!0},paint:{}},Ni={id:st,source:rt,type:"symbol",filter:["==","$type","Point"],layout:{"icon-image":["get","icon"],"icon-size":["get","iconSize"],"icon-allow-overlap":!1,"symbol-sort-key":["get","type"]}},$i={id:Ci,source:rt,type:"line",filter:["all",["==","$type","LineString"]],paint:{"line-color":"#f00","line-width":3},layout:{}},Di=[$i,ki,Ni],Qs=Object.freeze(Object.defineProperty({__proto__:null,ARROW_ICON:Oi,ARROW_ICON_NAME:xe,END_ICON:Ii,END_ICON_NAME:ve,LAYER_LIST:Di,NAME:Vs,NORMAL_ICON:Ti,NORMAL_ICON_NAME:we,START_ICON:Ai,START_ICON_NAME:ye,TRACK_ARROW_LAYER:ki,TRACK_ARROW_LAYER_NAME:Li,TRACK_ICON_LAYER:Ni,TRACK_ICON_LAYER_NAME:st,TRACK_LINE_LAYER:$i,TRACK_LINE_LAYER_NAME:Ci,TRACK_SOURCE_NAME:rt},Symbol.toStringTag,{value:"Module"}));class to extends nt{hoverId=null;hoverPointId=null;track;_move=()=>{};_leave=()=>{};_moveEnd=()=>{};constructor(t,i){super(t),this.track=i}off(){this.context.map.off("mousemove",st,this._move),this.context.map.off("mouseleave",st,this._leave),this.context.map.off("moveend",this._moveEnd)}on(){this.context.map.on("mousemove",st,this._move),this.context.map.on("mouseleave",st,this._leave),this.context.map.on("moveend",this._moveEnd)}onAdd(){this._move=this.onMove.bind(this),this._leave=this.onLeave.bind(this),this._moveEnd=this.onMoveEnd.bind(this),this.on()}onRemove(){this.off()}onMoveEnd(){this.track.render()}onMove(t){if(t.features?.length){if(this.context.map.getCanvasContainer().style.cursor="pointer",this.hoverId===(t.features[0].id??t.features[0].properties.id))return;this.hoverId&&this.unhover(),this.hoverId=t.features[0].id??t.features[0].properties.id,this.hoverPointId=t.features[0].properties.pId,this.hover()}}onLeave(){this.unhover(),this.hoverId=null,this.hoverPointId=null,this.context.map.getCanvasContainer().style.cursor=""}hover(){if(!this.hoverId)return;const i=this.track.trackData.get(this.hoverId)?.find(r=>r.pId===this.hoverPointId),n="track-hover";this.context.events.emit(n,i),this.context.map.fire(n,i)}unhover(){if(!this.hoverId)return;const i=this.track.trackData.get(this.hoverId)?.find(r=>r.pId===this.hoverPointId),n="track-unhover";this.context.events.emit(n,i),this.context.map.fire(n,i)}}class eo extends mt{options;trackData=new Map;tooltips=[];collision;event;constructor(t,i){super(t),this.options=i,this.collision=new Vt(t),this.event=new to(t,this)}onAdd(){this.context.register.addSource(rt,{type:"geojson",dynamic:!0,data:{type:"FeatureCollection",features:[]}}),Di.forEach(t=>{this.context.register.addLayer(t)}),this.context.iconManage.loadSvg([{name:ye,svg:Ai},{name:ve,svg:Ii},{name:xe,svg:Oi},{name:we,svg:Ti}])}onRemove(){this.event.off()}load(t){const i=t[0].id,n=t.filter(r=>r.id===i).sort((r,s)=>r.time.getTime()-s.time.getTime());this.trackData.set(i,this.markItem(n))}remove(){this.removeAllTooltip(),this.event.off(),this.context.register.setGeoJSONData(rt,this.getFeature())}markItem(t){if(t.length===0)return[];const i=t.map(r=>({...r,visible:!0,type:J.NORMAL}));i[0].type=J.START_END,i[i.length-1].type=J.START_END;let n=i[0].time.getTime();for(let r=1;r<i.length-1;r++){const s=i[r-1],o=i[r],a=i[r+1];let h=s.cog;h??=Mt(s.position.toArray(),o.position.toArray());let c=o.cog;c??=Mt(o.position.toArray(),a.position.toArray());const l=Math.abs(c-h);(l>180?360-l:l)>25&&(o.type=Math.min(o.type,J.SHARP_TURN));const m=h<.5,y=c<.5;m!==y&&(o.type=Math.min(o.type,J.STOP_GO)),o.type===J.NORMAL?o.time.getTime()-n>18e5&&(o.type=J.TIME_ANCHOR,n=o.time.getTime()):n=o.time.getTime()}return i}simplifyTrackBySlope(t,i=2){if(t.length<=2)return t;const n=[t[0]];let r=t[0];for(let s=1;s<t.length-1;s++){const o=t[s],a=t[s+1],h=Mt(r.position.toArray(),o.position.toArray()),c=Mt(o.position.toArray(),a.position.toArray());let l=Math.abs(h-c);l>180&&(l=360-l),l>i&&(n.push(o),r=o)}return n.push(t[t.length-1]),n}simplifyTrackByZoom(t,i){let n=0;return i<8?n=10:i<10?n=5:i<13?n=2:i<16?n=1:n=0,n===0||t.length<10?t:this.simplifyTrackBySlope(t,n)}getFeature(){const t=[];for(const i of this.trackData.keys()){const n=this.trackData.get(i);if(n){const s=[...this.simplifyTrackByZoom(n,this.context.map.getZoom())].sort((l,u)=>l.time.getTime()-u.time.getTime()),o=s.length,a=s.map(l=>l.position.toArray()),h=s[o-1],c={id:i,startTime:s[0].time.getTime(),endTime:h.time.getTime(),count:n.length};s.forEach((l,u)=>{let m=we,y=.2;u===0?(m=ye,y=.4):u===o-1&&(m=ve,y=.4),t.push(Dt(l.position.toArray(),{...l,icon:m,iconSize:y,isStartEnd:u===0||u===o-1,time:new Date(l.time).getTime()},{id:l.pId}))}),t.push(Pt(a,c,{id:i}))}}return t}collisionTooltip(){this.collision.load(this.createCollisions()).forEach(t=>{const i=this.tooltips.find(n=>n.id===t.id);i&&(t.visible?i.setAnchor(t.dir):i.hide())})}createCollisions(){return this.tooltips.map(t=>({...t.getSimpleBbox(),id:t.id}))}createTooltip(){const{width:t,height:i}=this.context.map.getCanvas(),n=[[0,0],[t,i]],r=this.context.map.queryRenderedFeatures(n,{layers:[st]});if(r.length===0)return;const s=(o,a)=>{let h=document.getElementById(o);if(h)return h;h=document.createElement("div"),h.id=`${o}-track-name-box`,h.classList.add("track-name-box");const c=document.createElement("div");return c.innerText=a,c.classList.add("track-name"),h.appendChild(c),h};this.tooltips=r.map(o=>new It(this.context.map,{id:o.properties.pId,position:new A.LngLat(o.geometry.coordinates[0],o.geometry.coordinates[1]),className:"mapbox-gl-track-name-tooltip",offsetX:5,offsetY:25,element:s(o.properties.pId,Ei(Number(o.properties.time)).format("YYYY-MM-DD HH:mm:ss")),anchor:"bottom-right",visible:!1})),this.collisionTooltip()}removeAllTooltip(){this.tooltips.forEach(t=>{t.remove()}),this.tooltips=[],this.collision.clear()}render(){this.removeAllTooltip(),this.createTooltip(),this.context.register.setGeoJSONData(rt,this.getFeature())}}M.AisShip=ge,M.BaseShip=Ht,M.CMap=yt,M.Cache=be,M.Collision=Vt,M.CollisionItem=Ee,M.Context=mi,M.IconManager=ut,M.Module=mt,M.Ship=Gs,M.ShipVars=qs,M.Tooltip=It,M.Track=eo,M.TrackVars=Qs,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
|
|
76
76
|
//# sourceMappingURL=index.umd.js.map
|