UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 3.71 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import e from"../../Color.js";import n from"../support/LabelClass.js";import o from"../support/LabelExpressionInfo.js";import{fetchClientDataAtKeys as a}from"../../rest/knowledgeGraphService.js";import r from"../../symbols/CIMSymbol.js";import l from"../../symbols/TextSymbol.js";const t={initializeLayersFromClientData:async(e,n,o)=>{if(n||(n=[...e.layers,...e.tables].map((e=>e.graphTypeName))),0===n?.length)return;const r=new Map;for(const a of n)r.set(a,s(e,a));const l=await a(e.dataManager.knowledgeGraph,Array.from(r.values()),{requestOptions:{signal:o?.signal}});for(const a of[...e.layers,...e.tables]){const n=a.objectType.name;if(null==n)continue;const o=l.get(s(e,n));if(o){const e=JSON.parse(o);null===e||"object"!=typeof e||e.hasOwnProperty("showLabels")||(e.showLabels=!1),a.read(e,{origin:"service"})}}}},s=(e,n)=>"knowledge-graph"===e.type?`${n}/Map`:`${n}/LinkChart/LinkChartSubLayer`;async function i(e,n,o){return t.initializeLayersFromClientData(e,n,o)}const b=["#4a0932","#b31515","#18382e","#a64f1b","#102432","#8c213f","#ed9310","#2c6954","#144d59","#ffc730","#75351e","#454f4b","#78b1c2","#191921","#8f8f82","#9be0c0","#dbb658","#87b051","#11495c","#c43541","#9c5596","#44498b","#ad9d63","#86afb3","#5c98ca","#b0bfa2","#73241f","#b86b53","#d9d78c","#3e756d","#f260a1","#a0d17d","#c27c30","#eb82eb","#ffdf3c","#ffb259","#ab52b3","#3cccb4","#0095ba","#d92b30"],c="#8f8f82";function f(n){return n<0||n>=b.length?new e(c):new e(b[n])}function m(e){const n=e.toArray();return new r({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,style:"solid",width:.75,color:n},{type:"CIMVectorMarker",enable:!0,size:6,markerPlacement:{type:"CIMMarkerPlacementOnLine",angleToLine:!0,relativeTo:"LineMiddle"},frame:{xmin:-10,ymin:-5,xmax:0,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[-12,-3.47],[-12,3.6],[1.96,-.03],[-12,-3.47]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:n}]}}]}]}}})}function p(e){let n="ESRI__ID",o=4;for(const a of e)if(a.name){if("name"===a.name.toLowerCase()){n=a.name;break}a.name.toLowerCase().includes("name")?(n=a.name,o=2):"esriFieldTypeString"===a.fieldType&&o>3&&(n=a.name,o=3)}return n}function y(e,a,r){const t={color:[80,80,80],haloColor:[255,255,255],haloSize:.7,font:{size:10,weight:"normal"}},s=new n({labelExpressionInfo:new o({expression:"ESRI__ID"===r?`${a}`:`$feature.${r}`}),labelPlacement:"above-center",symbol:new l(t)}),i=new n({labelExpressionInfo:new o({expression:`'${a}' + IIf($feature.ESRI__AggregationCount>1, ' (' + $feature.ESRI__AggregationCount + ')', '')`}),labelPlacement:"center-along",labelPosition:"parallel",repeatLabel:!1,symbol:new l({...t,yoffset:"12px"})});return"entity"===e?[s]:[i]}function w(e,a,r){const t={color:[255,255,255],haloColor:[0,0,0],haloSize:.7,font:{size:10,weight:"bold"}},s="ESRI__ID"===r?`${e}`:`$feature.${r}`;return"point"===a?[new n({labelExpressionInfo:new o({expression:s}),labelPlacement:"above-center",symbol:new l(t)})]:"polyline"===a?[new n({labelExpressionInfo:new o({expression:s}),labelPlacement:"center-along",repeatLabel:!0,symbol:new l(t)})]:"polygon"===a?[new n({labelExpressionInfo:new o({expression:s}),labelPlacement:"always-horizontal",symbol:new l(t)})]:null}export{c as fallbackKGSublayerSymbolHexColor,m as getDefaultLCRelationshipSublayerSymbol,p as getDisplayLabelProperty,f as getKGSublayerSymbolColor,y as getLinkChartDefaultLabelingInfo,w as getMapDefaultLabelingInfo,i as initializeLayersFromClientData,t as layerUtils};