UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.67 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import e from"../../core/Error.js";import{isSceneServiceLayer as o}from"../../layers/support/layerUtils.js";import n from"../WebStyleSymbol.js";import{to3D as t}from"./symbolConversion.js";import{readSymbol as s,isSymbol3D as l}from"./typeUtils.js";function r(e,o,n,t){const s=a(e,{},{context:t,isLabelSymbol:!1});null!=s&&(o[n]=s)}function i(e,o,n,t){const s=a(e,{},{context:t,isLabelSymbol:!0});null!=s&&(o[n]=s)}function p(e){return l(e)||e instanceof n}function y(e){return"polygon-3d"===e?.type||"line-3d"===e?.type}function a(n,s,l){if(null==n)return null;const{context:r,isLabelSymbol:i}=l,a=r?.origin,m=r?.messages;if("web-scene"===a&&!p(n)){const o=t(n,{retainCIM:!0,hasLabelingContext:i});return null!=o.symbol?o.symbol.write(s,r):(m?.push(new e("symbol:unsupported",`Symbols of type '${n.declaredClass}' are not supported in scenes. Use 3D symbology instead when working with WebScene and SceneView`,{symbol:n,context:r,error:o.error})),null)}return o(r?.layer)&&y(n)?(m?.push(new e("symbol:unsupported",`Symbols of type '${n.declaredClass}' are not supported on layers of type '${r?.layer?.declaredClass}'.`,{symbol:n,context:r})),null):("web-map"===a||"portal-item"===a&&!o(r?.layer))&&p(n)?(m?.push(new e("symbol:unsupported",`Symbols of type '${n.declaredClass}' are not supported in web maps and portal items. Use 2D symbology and CIMSymbol instead when working with MapView`,{symbol:n,context:r})),null):n.write(s,r)}function m(e,o){return s(e,null,o)}export{m as fromJSON,r as write,i as writeLabelSymbol};