UNPKG

@arcgis/map-components

Version:
2 lines 3.29 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import a from"./R3NYK6BO.js";import{a as w}from"./HZFVK34O.js";import"./AKBXFBDL.js";import"./LMBRORN7.js";import"./PBSJQPB2.js";import{O as l,R as y,U as n,a as p,b as m,p as t,r as s,x as g}from"./WUJCCZQC.js";import"./3TTFCHAA.js";export default $arcgis.t(([G,u,v,L,f,b,{a:h,d:d}])=>{var k=p`.loader-container{display:flex;justify-content:center;padding-bottom:var(--calcite-spacing-md)}`,o=12,c=class extends l{constructor(){super(...arguments),this._graphicsLayerName="arcgis-utility-network-aggregated-geometry-graphics",this._messages=w({blocking:!0}),this._graphics=[],this._addAggregatedGeometryToView=()=>{let e=this.geometry,{line:i,multipoint:r,polygon:_}=e;this._graphics=[i,r,_].filter(a=>a!=null).map(a=>this._makeGraphicFromGeometry(a)),this._graphicsLayer.addMany(this._graphics)},this._createGraphicsLayer=()=>{let e=this.view.map,i=this._graphicsLayerName,r=e.findLayerById(i);if(r&&d(r)){this._graphicsLayer=r;return}this._graphicsLayer=new v({id:i,listMode:"hide",title:i}),h(this.view,this._graphicsLayer)},this.hideGraphics=!1,this.graphicsColor=new G([255,255,0,.6]),this.autoDestroyDisabled=!1,this.arcgisHideGraphicsChange=g()}static{this.properties={geometry:0,hideGraphics:5,graphicsColor:0,view:0,autoDestroyDisabled:5}}static{this.styles=k}async destroy(){this.view?.map&&this._graphicsLayer&&this.view.map.remove(this._graphicsLayer),await this.manager.destroy()}connectedCallback(){super.connectedCallback(),this.view&&this._graphicsLayer&&h(this.view,this._graphicsLayer)}load(){!this.geometry||!this.view?.map||this._createGraphicsLayer()}willUpdate(e){if(e.has("graphicsColor")&&this._updateGraphicSymbols(),e.has("geometry")&&(this._graphicsLayer?.removeAll(),this._addAggregatedGeometryToView()),e.has("view")){let i=e.get("view");i?.map&&this._graphicsLayer&&(i.map.remove(this._graphicsLayer),this._createGraphicsLayer(),this._addAggregatedGeometryToView())}}loaded(){this.geometry||t("error",this,s("geometry")),this.view?this.view.map||t("error",this,s("The property `view` was provided, but `view.map` is null. Cannot draw aggregated geometry.")):t("error",this,s("view"))}_handleShowGraphicsChange(){this.hideGraphics=!this.hideGraphics,this.hideGraphics?this._graphicsLayer?.removeAll():this._graphicsLayer?.addMany(this._graphics),this.arcgisHideGraphicsChange.emit(this.hideGraphics)}_makeGraphicFromGeometry(e){return new u({geometry:e,symbol:this._makeSymbolForGeometry(e)})}_makeSymbolForGeometry(e){let i=this.graphicsColor;switch(e.type){case"multipoint":return new b({color:i,size:o,outline:{color:i,width:0}});case"polygon":return new L({color:i,outline:{color:i,width:o}});case"polyline":return new f({color:i,width:o})}}_updateGraphicSymbols(){this._graphicsLayer?.graphics.forEach(e=>{let i=e.geometry;e.symbol=this._makeSymbolForGeometry(i)})}render(){return m`<calcite-switch .checked=${!this.hideGraphics} .label=${this._messages.labels.showGraphicsToggle} label-text-end=${this._messages.showGraphics??y} @calciteSwitchChange=${this._handleShowGraphicsChange}></calcite-switch>`}};n("arcgis-utility-network-aggregated-geometry",c);return c},"Color","Graphic","layers/GraphicsLayer","symbols/SimpleFillSymbol","symbols/SimpleLineSymbol","symbols/SimpleMarkerSymbol",a)