12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import"../../libs/maquette/projection.js";import{h as r}from"../../libs/maquette/h.js";import"../../libs/maquette/projector.js";const s={bottom:"esri-text-overlay-item-anchor-bottom","bottom-right":"esri-text-overlay-item-anchor-bottom-right","bottom-left":"esri-text-overlay-item-anchor-bottom-left",top:"esri-text-overlay-item-anchor-top","top-right":"esri-text-overlay-item-anchor-top-right","top-left":"esri-text-overlay-item-anchor-top-left",center:"esri-text-overlay-item-anchor-center",right:"esri-text-overlay-item-anchor-right",left:"esri-text-overlay-item-anchor-left"};let l=class extends e{constructor(t){super(t),this.x=0,this.y=0,this.text="-",this.fontSize=14,this.anchor="center",this.visible=!0,this._backgroundColor="rgba(0, 0, 0, 0.6)",this._textColor="white",this._textShadowColor=[0,0,0],this._textShadowSize=1}get position(){return[this.x,this.y]}set position(t){this._set("x",t[0]),this._set("y",t[1])}get _textShadow(){const[t,e,o]=this._textColor;return`0 0 ${this._textShadowSize}px rgb(${t}, ${e}, ${o})`}get _padding(){return.5*this.fontSize}get _borderRadius(){return this._padding}render(){return r("div",{classes:this._cssClasses(),styles:{left:Math.floor(this.x)+"px",top:Math.floor(this.y)+"px",visibility:this.visible?"visible":"hidden",fontSize:this.fontSize+"px",lineHeight:this.fontSize+"px",backgroundColor:this._backgroundColor,color:this._textColor,padding:this._padding+"px",borderRadius:this._borderRadius+"px",textShadow:this._textShadow}},[this.text])}renderCanvas(t){if(!this.visible)return;const e=t.font.replace(/^(.*?)px/,"");t.font=`${this.fontSize}px ${e}`;const o=this._padding,i=this._borderRadius,r=t.measureText(this.text).width,s=this.fontSize,l=n[this.anchor];t.textAlign="center",t.textBaseline="middle";const h=r+2*o,a=s+2*o,x=this.x+l.x*h,p=this.y+l.y*a;this._roundedRect(t,x,p,h,a,i),t.fillStyle=this._backgroundColor,t.fill();const d=this.x+(l.x+.5)*h,c=this.y+(l.y+.5)*a;this._renderTextShadow(t,this.text,d,c),t.fillStyle=this._textColor,t.fillText(this.text,d,c)}_renderTextShadow(t,e,o,i){t.lineJoin="miter",t.fillStyle=`rgba(${this._textShadowColor[0]}, ${this._textShadowColor[1]}, ${this._textShadowColor[2]}, ${1/h.length})`;const r=this._textShadowSize;for(const[s,l]of h)t.fillText(e,o+r*s,i+r*l)}_roundedRect(t,e,o,i,r,s){t.beginPath(),t.moveTo(e,o+s),t.arcTo(e,o,e+s,o,s),t.lineTo(e+i-s,o),t.arcTo(e+i,o,e+i,o+s,s),t.lineTo(e+i,o+r-s),t.arcTo(e+i,o+r,e+i-s,o+r,s),t.lineTo(e+s,o+r),t.arcTo(e,o+r,e,o+r-s,s),t.closePath()}_cssClasses(){const t={"esri-text-overlay-item":!0};for(const e in s)t[s[e]]=this.anchor===e;return t}};t([o()],l.prototype,"x",void 0),t([o()],l.prototype,"y",void 0),t([o()],l.prototype,"position",null),t([o()],l.prototype,"text",void 0),t([o()],l.prototype,"fontSize",void 0),t([o()],l.prototype,"anchor",void 0),t([o()],l.prototype,"visible",void 0),t([o()],l.prototype,"_backgroundColor",void 0),t([o()],l.prototype,"_textColor",void 0),t([o()],l.prototype,"_textShadowColor",void 0),t([o()],l.prototype,"_textShadowSize",void 0),t([o()],l.prototype,"_textShadow",null),t([o()],l.prototype,"_padding",null),t([o()],l.prototype,"_borderRadius",null),l=t([i("esri.views.overlay.TextOverlayItem")],l);const n={bottom:{x:-.5,y:-1,textAlign:"center",textBaseline:"bottom"},"bottom-left":{x:0,y:-1,textAlign:"left",textBaseline:"bottom"},"bottom-right":{x:-1,y:-1,textAlign:"right",textBaseline:"bottom"},center:{x:-.5,y:-.5,textAlign:"center",textBaseline:"middle"},left:{x:0,y:-.5,textAlign:"left",textBaseline:"middle"},right:{x:-1,y:-.5,textAlign:"right",textBaseline:"middle"},top:{x:-.5,y:0,textAlign:"center",textBaseline:"top"},"top-left":{x:0,y:0,textAlign:"left",textBaseline:"top"},"top-right":{x:-1,y:0,textAlign:"right",textBaseline:"top"}},h=[];{const t=16;for(let e=0;e<360;e+=360/t)h.push([Math.cos(Math.PI*e/180),Math.sin(Math.PI*e/180)])}const a=l;export{a as default};
|