@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.25 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import o from"../../../Graphic.js";import i from"../../../core/Collection.js";import e from"../../../symbols/SimpleFillSymbol.js";import t from"../../../symbols/SimpleLineSymbol.js";import l from"../../../symbols/SimpleMarkerSymbol.js";import r from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import a from"../../../views/interactive/snapping/SnappingOptions.js";import c from"../../Sketch/SketchViewModel.js";const p=[227,27,21,.6],n=[21,244,21,.6],s=12,h=[{color:[255,0,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#ff0000"},{color:[255,0,255,.6],haloOpacity:.9,fillOpacity:.2,hex:"#ff00ff"},{color:[217,188,255,.6],haloOpacity:.9,fillOpacity:.2,hex:"#D9BCFF"},{color:[0,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#00ff00"},{color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#ffff00"},{color:[0,0,255,.6],haloOpacity:.9,fillOpacity:.2,hex:"#0000ff"},{color:[255,165,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#ffa500"},{color:[0,0,0,.5],haloOpacity:.9,fillOpacity:.2,hex:"#000000"}];class f{constructor(){this.highlightColor=[...h]}addCustomColor(o){this.highlightColor=[...h];this.highlightColor.some((i=>i.hex.toLowerCase()===o.hex.toLowerCase()))||this.highlightColor.push(o)}getFlagGraphic(o,i,e,t){const l="starting-point"===i?n:p;if("polygon"===o.type){const i=o;i.centroid&&(o=i.centroid)}if(t){return this.makeGraphic(o,l,e?.attributes,null,t)}return this.makeGraphic(o,l,e?.attributes)}initializeSketch(o,e,t){const l=new i;return t.forEach((o=>l.add(new r({layer:o,enabled:!0})))),new c({layer:e,view:o,snappingOptions:new a({enabled:!0,featureEnabled:!0,featureSources:l})})}makeGraphic(i,r,a,c,p){let n,h=i;switch(i.type){case"multipoint":n=new l({color:r,size:s,outline:{color:r,width:0}}),c&&(h=i);break;case"point":n=p||new l({color:r,size:s,outline:{color:r,width:0}}),c&&(h=i);break;case"polyline":n=new t({color:r,width:s}),c&&(h=i);break;case"polygon":n=new e({color:r,outline:{color:r,width:s}}),c&&(h=i)}return new o({geometry:h,symbol:n,attributes:a??null})}}export{f as GraphicHandler,p as barrierColor,h as defaultSwatchColors,n as startingPointColor};