@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.28 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import o from"../../../Graphic.js";import i from"../../../core/Collection.js";import t from"../../../geometry/Point.js";import{polygonCentroidPoint as e}from"../../../geometry/support/centroid.js";import l from"../../../symbols/SimpleFillSymbol.js";import r from"../../../symbols/SimpleLineSymbol.js";import a from"../../../symbols/SimpleMarkerSymbol.js";import c from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import p from"../../../views/interactive/snapping/SnappingOptions.js";import s from"../../Sketch/SketchViewModel.js";const n=[227,27,21,.6],h=[21,244,21,.6],f=12,m=[{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 y{constructor(){this.highlightColor=[...m]}addCustomColor(o){this.highlightColor=[...m];this.highlightColor.some(i=>i.hex.toLowerCase()===o.hex.toLowerCase())||this.highlightColor.push(o)}getFlagGraphic(o,i,l,r){const a="starting-point"===i?h:n;if("polygon"===o.type){const i=e(o);o=i?t.fromJSON(i):null}if(r){return this.makeGraphic(o,a,l?.attributes,null,r)}return this.makeGraphic(o,a,l?.attributes)}initializeSketch(o,t,e){const l=new i;return e.forEach(o=>l.add(new c({layer:o,enabled:!0}))),new s({layer:t,view:o,snappingOptions:new p({enabled:!0,featureEnabled:!0,featureSources:l})})}makeGraphic(i,t,e,c,p){let s,n=i;switch(i.type){case"multipoint":s=new a({color:t,size:f,outline:{color:t,width:0}}),c&&(n=i);break;case"point":s=p||new a({color:t,size:f,outline:{color:t,width:0}}),c&&(n=i);break;case"polyline":s=new r({color:t,width:f}),c&&(n=i);break;case"polygon":s=new l({color:t,outline:{color:t,width:f}}),c&&(n=i)}return new o({geometry:n,symbol:s,attributes:e??null})}}export{y as GraphicHandler,n as barrierColor,m as defaultSwatchColors,h as startingPointColor};