Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
8.2 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("require exports ../../core/has ../../support/arcadeOnDemand ./gfxUtils ./previewUtils ./renderUtils ./utils ../../widgets/Legend/styles/support/relationshipUtils ../../widgets/Legend/support/relationshipRampUtils".split(" "),function(t,u,J,A,E,F,B,r,G,H){function I(a,b){if(b&&(a.style.filter=r.getCSSFilterFromEffectList(b),b=b.effects))for(const c of b)if("drop-shadow"===c?.type){0>c.offsetX?a.style.marginLeft=`${Math.abs(c.offsetX)}px`:a.style.marginRight=`${c.offsetX}px`;break}}async function C(a,
b){switch(a.type){case "web-style":var {previewWebStyleSymbol:c}=await new Promise((g,d)=>t(["./previewWebStyleSymbol"],g,d));return c(a,C,b);case "label-3d":case "line-3d":case "mesh-3d":case "point-3d":case "polygon-3d":return{previewSymbol3D:c}=await new Promise((g,d)=>t(["./previewSymbol3D"],g,d)),c(a,b);case "simple-marker":case "simple-line":case "simple-fill":case "picture-marker":case "picture-fill":case "text":return{previewSymbol2D:c}=await new Promise((g,d)=>t(["./previewSymbol2D"],g,d)),
c(a,b);case "cim":return{previewCIMSymbol:c}=await new Promise((g,d)=>t(["./previewCIMSymbol"],g,d)),c(a,b)}}function z(a){return a&&"opacity"in a?a.opacity*z(a.parent):1}function y(a){if(a)return"renderer"in a?a.renderer:void 0}let x=null;const D=[255,255,255];u.getDisplayedColor=async function(a,b){if(a){var {layer:c,sourceLayer:g}=a,d=z(c??g);if(null!=a.symbol&&(null==b||!0!==b.ignoreGraphicSymbol))return a="web-style"===a.symbol.type?await r.fetchWebStyleSymbol(a.symbol,b):a.symbol.clone(),r.getColorFromSymbol(a,
d);var e=b?.renderer??y(c)??y(g),f=e&&"getSymbolAsync"in e?await e.getSymbolAsync(a,b):void 0;if(f){f="web-style"===f.type?await r.fetchWebStyleSymbol(f,b):f.clone();f=r.getColorFromSymbol(f,d);if(!(e&&"visualVariables"in e)||"visualVariables"in e&&!e.visualVariables||"visualVariables"in e&&!e.visualVariables?.length)return f;"arcadeRequiredForVisualVariables"in e&&e.arcadeRequiredForVisualVariables&&null==b?.arcade&&(b={...b},b.arcade=await A.loadArcade());var {getColor:m,getOpacity:p}=await new Promise((k,
l)=>t(["../../renderers/visualVariables/support/visualVariableUtils"],k,l)),n=[],h=[];for(const k of e.visualVariables)switch(k.type){case "color":n.push(k);break;case "opacity":h.push(k)}e=(e=0<n.length?n[n.length-1]:null)?m(e,a,b):f;a=(f=0<h.length?h[h.length-1]:null)?p(f,a,b):null;null!=d&&(a=null!=a?a*d:d);return e?r.applyOpacityToColor(e,a):null}}};u.getDisplayedSymbol=async function(a,b){if(a){var c=a.sourceLayer,g=(null!=b&&(b.useSourceLayer??!1)?c:a.layer)??c;c=z(g);if(null!=a.symbol&&(null==
b||!0!==b.ignoreGraphicSymbol))return a="web-style"===a.symbol.type?await r.fetchWebStyleSymbol(a.symbol,{...b,cache:null!=b?b.webStyleCache:null}):a.symbol.clone(),r.applyColorToSymbol(a,null,c),a;var d=b?.renderer??y(g);if(g=d&&"getSymbolAsync"in d?await d.getSymbolAsync(a,b):null){g="web-style"===g.type?await g.fetchSymbol({...b,cache:null!=b?b.webStyleCache:null}):g.clone();if(!(d&&"visualVariables"in d&&d.visualVariables?.length))return r.applyColorToSymbol(g,null,c),g;"arcadeRequiredForVisualVariables"in
d&&d.arcadeRequiredForVisualVariables&&null==b?.arcade&&(b={...b},b.arcade=await A.loadArcade());var {getColor:e,getOpacity:f,getAllSizes:m,getRotationAngle:p}=await new Promise((v,w)=>t(["../../renderers/visualVariables/support/visualVariableUtils"],v,w)),n=[],h=[],k=[],l=[];for(var q of d.visualVariables)switch(q.type){case "color":n.push(q);break;case "opacity":h.push(q);break;case "rotation":l.push(q);break;case "size":q.target||k.push(q)}q=(q=!!n.length&&n[n.length-1])?e(q,a,b):null;h=(h=!!h.length&&
h[h.length-1])?f(h,a,b):null;null!=c&&(h=null!=h?h*c:c);r.applyColorToSymbol(g,q,h);k.length&&(c=m(k,a,b),await r.applySizesToSymbol(g,c));for(const v of l)r.applyRotationToSymbol(g,p(v,a,b),v.axis);return g}}};u.getLegendLabel=async function(a,b,c){if(a){var {layer:g,sourceLayer:d}=a,e=c?.renderer??y(g)??y(d);if(!e)return null;if("visualVariables"in e&&e.visualVariables?.length){const {getRampStops:m}=await new Promise((k,l)=>t(["../../widgets/Legend/support/colorRampUtils"],k,l)),{getRampStops:p}=
await new Promise((k,l)=>t(["../../widgets/Legend/support/sizeRampUtils"],k,l)),{getDateFormatOptions:n}=await new Promise((k,l)=>t(["../../widgets/Legend/support/utils"],k,l));let h=null;for(const k of e.visualVariables){var f=b?n(g,k,b.timeZone):null;let l=null;switch(k.type){case "color":l=await m(k,null,f);break;case "opacity":l=await m(k);break;case "size":k.target||(l=await p(e,k,null,c?.scale||b?.scale,b,f))}if(l?.length&&(f=l.find((q,v)=>{const w=a.attributes[k.field];return 0===v?w>=q.value:
v===l?.length-1?w<=q.value:q.value===w}))){h=f.label;break}}if(h)return h}switch(e.type){case "class-breaks":return b="getClassBreakInfo"in e?await e.getClassBreakInfo(a,c):null,b?.label??(b&&1<e.classBreakInfos?.length)?`${b.minValue} - ${b.maxValue}`:null;case "unique-value":return("getUniqueValueInfo"in e?await e.getUniqueValueInfo(a,c):null)?.label}return null}};u.renderColorRampPreviewHTML=function(a,b={}){var c="horizontal"===b.align;const g=b.width??(c?75:24),d=b.height??(c?24:75);var e=b.gradient??
!0,f=window.devicePixelRatio,m=g*f,p=d*f;f=document.createElement("canvas");f.width=m;f.height=p;f.ariaLabel=b.ariaLabel??null;f.style.width=`${g}px`;f.style.height=`${d}px`;const n=f.getContext("2d");var h=c?m:0;const k=c?0:p;if(e){const l=n.createLinearGradient(0,0,h,k);c=a.length;const q=1===c?0:1/(c-1);a.forEach((v,w)=>l.addColorStop(w*q,v.toString()));n.fillStyle=l;n.fillRect(0,0,m,p)}else{m=c?m/a.length:m;p=c?p:p/a.length;h=e=0;for(const l of a)n.fillStyle=l.toString(),n.fillRect(e,h,m,p),e=
c?e+m:0,h=c?0:h+p}a=document.createElement("div");a.style.width=`${g}px`;a.style.height=`${d}px`;I(a,b?.effectList);a.appendChild(f);return a};u.renderDotDensityPreviewHTML=function(a,b,c){const {backgroundColor:g,outline:d,dotSize:e}=a;var f=c?.swatchSize||F.SymbolSizeDefaults.size;const m=Math.round(f*f/Math.max(e,.5)**2*.8),p=window.devicePixelRatio;a=document.createElement("canvas");const n=f*p;a.width=n;a.height=n;a.style.width=`${a.width/p}px`;a.style.height=`${a.height/p}px`;const h=a.getContext("2d");
g&&(h.fillStyle=g.toCss(!0),h.fillRect(0,0,n,n),h.fill());h.fillStyle=b?.toCss(!0)??"";if(x&&x.length/2===m)for(b=0;b<2*m;b+=2)h.fillRect(x[b],x[b+1],e*p,e*p),h.fill();else for(x=[],b=0;b<2*m;b+=2){const k=Math.floor(Math.random()*(n-0+1)),l=Math.floor(Math.random()*(n-0+1));x.push(k,l);h.fillRect(k,l,e*p,e*p);h.fill()}d&&(d.color&&(h.strokeStyle=d.color.toCss(!0)),h.lineWidth=d.width,h.strokeRect(0,0,n,n));f=new Image(f,f);f.src=a.toDataURL();f.ariaLabel=c?.ariaLabel??null;f.alt=c?.ariaLabel??"";
return f};u.renderPieChartPreviewHTML=function(a,b={}){const c=b.radius||40;var g=2*Math.PI*c,d=a.length;const e=g/d,f=[],m=E.getStroke(b.outline);null!=m?.width&&(m.width*=2);(m||b.backgroundColor)&&f.push({shape:{type:"circle",cx:c,cy:c,r:c},fill:b.backgroundColor,stroke:m,offset:[0,0]});const p=b.values,n=p&&p.length===d&&100===p.reduce((k,l)=>k+l,0),h=[0];for(let k=0;k<d;k++){let l=null;n&&(l=p[k]*g/100,h.push(l+h[k]));f.push({shape:{type:"circle",cx:c,cy:c,r:c/2},fill:[0,0,0,0],stroke:{width:c,
dashArray:`${(l??e)/2} ${g}`,dashoffset:`-${n?h[k]/2:e/2*k}`,color:a[k]},offset:[0,0]})}d=null;a=2*c+(m?.width||0);if(g=b.holePercentage)m&&f.push({shape:{type:"circle",cx:c,cy:c,r:c*g},fill:null,stroke:m,offset:[0,0]}),d=a/2,d=[[{shape:{type:"circle",cx:d,cy:d,r:d},fill:D,stroke:m?{...m,color:D}:null,offset:[0,0]},{shape:{type:"circle",cx:d,cy:d,r:c*g},fill:[0,0,0],stroke:null,offset:[0,0]}]];return B.renderSymbol([f],[a,a],{effectView:b.effectList,ignoreStrokeWidth:!0,masking:d,rotation:-90,ariaLabel:b.ariaLabel})};
u.renderPreviewHTML=C;u.renderRelationshipRampPreviewHTML=function(a,b={}){const c=a?.authoringInfo;if("relationship"!==c?.type||!c?.numClasses||!a.uniqueValueInfos)return null;const {focus:g,numClasses:d}=c,e=H.getRelationshipRampElement({focus:g,numClasses:d,infos:a.uniqueValueInfos});a=b?.node||document.createElement("div");B.renderOnce(a,()=>G.renderRelationshipRamp(e,b.id||"relationship",{opacity:b.opacity||1,effectList:b.effectList,ariaLabel:b.ariaLabel}));return a};Object.defineProperty(u,
Symbol.toStringTag,{value:"Module"})});