UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 3.47 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as o}from"../chunks/tslib.es6.js";import{clone as t}from"../core/lang.js";import r from"../core/Logger.js";import{makeData as e}from"../core/urlUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{enumeration as s}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"./Symbol3DLayer.js";import{white as c,isBlack as a}from"./support/colors.js";import{IconSymbol3DLayerResource as p}from"./support/IconSymbol3DLayerResource.js";import{screenSizeProperty as m}from"./support/materialUtils.js";import{Symbol3DAnchorPosition2D as u}from"./support/Symbol3DAnchorPosition2D.js";import{Symbol3DIconOutline as h}from"./support/Symbol3DIconOutline.js";import{Symbol3DMaterial as y}from"./support/Symbol3DMaterial.js";var d;let f=class extends l{static{d=this}constructor(o){super(o),this.material=null,this.resource=null,this.type="icon",this.size=12,this.anchor="center",this.anchorPosition=null,this.outline=null,this.angle=0}clone(){return new d({anchor:this.anchor,anchorPosition:t(this.anchorPosition),enabled:this.enabled,material:t(this.material),outline:t(this.outline),resource:t(this.resource),angle:this.angle,size:this.size})}static fromSimpleMarkerSymbol(o){const t=o.color||c,e=g(o),i=o.outline&&o.outline.width>0?{size:o.outline.width,color:(o.outline.color||c).clone()}:null;return new d({size:o.size,angle:o.angle,resource:{primitive:w((()=>r.getLogger(this.prototype)),o.style)},material:{color:t},outline:i,anchor:e?"relative":void 0,anchorPosition:e})}static fromPictureMarkerSymbol(o){const t=!o.color||a(o.color)?c:o.color,r=g(o);return new d({size:o.width<=o.height?o.height:o.width,angle:o.angle,resource:{href:o.url},material:{color:t.clone()},anchor:r?"relative":void 0,anchorPosition:r})}static fromCIMSymbol(o){return new d({resource:{href:e({mediaType:"application/json",data:JSON.stringify(o.data)})}})}};function g(o){const t="width"in o?o.width:o.size,r="height"in o?o.height:o.size,e=b(o.xoffset),i=b(o.yoffset);return(e||i)&&t&&r?{x:-e/t,y:i/r}:null}function b(o){return isFinite(o)?o:0}o([i({type:y,json:{write:!0}})],f.prototype,"material",void 0),o([i({type:p,json:{write:!0}})],f.prototype,"resource",void 0),o([s({Icon:"icon"},{readOnly:!0})],f.prototype,"type",void 0),o([i({...m,json:{write:{isRequired:!0}}})],f.prototype,"size",void 0),o([s({center:"center",left:"left",right:"right",top:"top",bottom:"bottom",topLeft:"top-left",topRight:"top-right",bottomLeft:"bottom-left",bottomRight:"bottom-right",relative:"relative"},{default:"center"})],f.prototype,"anchor",void 0),o([i({type:u,json:{type:[Number],read:{reader:o=>new u({x:o[0],y:o[1]})},write:{writer:(o,t)=>{t.anchorPosition=[o.x,o.y]},overridePolicy(){return{enabled:"relative"===this.anchor}}}}})],f.prototype,"anchorPosition",void 0),o([i({type:h,json:{write:!0}})],f.prototype,"outline",void 0),o([i({type:Number,json:{write:!0,default:0}})],f.prototype,"angle",void 0),f=d=o([n("esri.symbols.IconSymbol3DLayer")],f);const j={circle:"circle",cross:"cross",diamond:"kite",square:"square",x:"x",triangle:"triangle",path:null};function w(o,t){const r=j[t];return r||(o().warn(`${t} cannot be mapped to Icon symbol. Fallback to "circle"`),"circle")}export{f as default};