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.
 
 

21 lines
9.5 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("../../chunks/tslib.es6 ../../intl ../../core/Accessor ../../core/Collection ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../../core/accessorSupport/get ../../views/2d/layers/features/layerAdapters/featureReductionUtils ./support/ActiveLayerInfo ../../intl/locale".split(" "),function(k,h,u,p,g,l,E,F,G,v,w,q,r,x){const t=p.ofType(r),y=new Set("esri.layers.BuildingSceneLayer esri.layers.CatalogLayer esri.layers.CSVLayer esri.layers.FeatureLayer esri.layers.GeoJSONLayer esri.layers.GeoRSSLayer esri.layers.GroupLayer esri.layers.HeatmapLayer esri.layers.ImageryLayer esri.layers.ImageryTileLayer esri.layers.MapImageLayer esri.layers.OGCFeatureLayer esri.layers.OrientedImageryLayer esri.layers.PointCloudLayer esri.layers.StreamLayer esri.layers.SceneLayer esri.layers.SubtypeGroupLayer esri.layers.TileLayer esri.layers.VoxelLayer esri.layers.WFSLayer esri.layers.WMSLayer esri.layers.WMTSLayer esri.layers.WCSLayer esri.layers.LinkChartLayer esri.layers.catalog.CatalogFootprintLayer esri.layers.catalog.CatalogDynamicGroupLayer esri.layers.knowledgeGraph.KnowledgeGraphSublayer".split(" ")),
z=["view.basemapView.baseLayerViews","view.groundView.layerViews","view.layerViews","view.basemapView.referenceLayerViews"];h=class extends u{constructor(a){super(a);this._layerViewByLayerId={};this._layerInfosByLayerViewId={};this._activeLayerInfosByLayerViewId={};this._activeLayerInfosWithNoParent=new p;this.activeLayerInfos=new t;this.respectLayerDefinitionExpression=this.keepCacheOnDestroy=this.hideLayersNotInCurrentView=this.groundLegendVisible=this.basemapLegendVisible=!1;this.respectLayerVisibility=
!0;this.layerInfos=[];this.view=null}initialize(){this.addHandles(g.watch(()=>this.view,()=>this._viewHandles(),g.initial),"view");this.addHandles(x.onLocaleChange(()=>this._refresh()))}destroy(){this._destroyViewActiveLayerInfos();this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles("state");this.view&&this.addHandles(g.watch(()=>this.state,()=>this._stateHandles(),g.initial),"state")}_stateHandles(){this._resetAll();"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles(["all-layer-views",
"legend-properties"]);this._destroyViewActiveLayerInfos();this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(a){this.removeHandles(a);const b=this._activeLayerInfosByLayerViewId[a];delete this._activeLayerInfosByLayerViewId[a];b?.parent&&b.parent.children.remove(b)}_watchPropertiesAndAllLayerViews(){var {view:a}=this;a&&({allLayerViews:a}=a,a.length&&this._refresh(),
this.addHandles(a.on("change",b=>this._propertiesChangeHandle()),"all-layer-views"),this.addHandles(g.watch(()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible],()=>this._propertiesChangeHandle()),"legend-properties"))}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos();this._refresh()}_refresh(){this._layerInfosByLayerViewId={};this.activeLayerInfos.removeAll();this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,
this).forEach(this._generateActiveLayerInfo,this);this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(a){const b=this.view;if(!(2>a.length)&&b){var d=[];a.forEach(c=>{if(!c.parent){var e=c.layer.parent;(e=(e=e&&"uid"in e&&this._layerViewByLayerId[e.uid])&&this._activeLayerInfosByLayerViewId[e.uid])&&a.includes(e)&&(d.push(c),c.parent=e,e.children.add(c),this._sortActiveLayerInfos(e.children))}});a.removeMany(d);var f={};b.allLayerViews.forEach((c,e)=>f[c.layer.uid]=e);a.sort((c,
e)=>(f[e.layer.uid]||0)-(f[c.layer.uid]||0))}}_generateLayerViews(){const a=[];z.filter(this._filterLayerViews,this).map(b=>w.get(this,b)).filter(b=>null!=b).forEach(this._collectLayerViews("layerViews",a));return a}_filterLayerViews(a){const b=!this.groundLegendVisible&&"view.groundView.layerViews"===a;return!(!this.basemapLegendVisible&&("view.basemapView.baseLayerViews"===a||"view.basemapView.referenceLayerViews"===a))&&!b}_collectLayerViews(a,b){const d=f=>{f&&f.forEach(c=>{b.push(c);d(c[a])});
return b};return d}_filterLayerViewsByLayerInfos(a){const b=this.layerInfos;return b&&b.length?b.some(d=>this._hasLayerInfo(d,a)):!0}_hasLayerInfo(a,b){const d=this._isLayerUIDMatching(a.layer,b.layer.uid);d&&(this._layerInfosByLayerViewId[b.uid]=a);return d}_isLayerUIDMatching(a,b){return a&&(a.uid===b||this._hasLayerUID(a.layers,b))}_hasLayerUID(a,b){return a&&a.some(d=>this._isLayerUIDMatching(d,b))}_isLayerViewSupported(a){return y.has(a.layer.declaredClass)?(this._layerViewByLayerId[a.layer.uid]=
a,!0):!1}_generateActiveLayerInfo(a){this._isLayerActive(a)?this._buildActiveLayerInfo(a):(this.removeHandles(a.uid),this.addHandles(g.watch(()=>[a.legendEnabled,a.layer?.legendEnabled],()=>this._layerActiveHandle(a)),a.uid))}_layerActiveHandle(a){this._isLayerActive(a)&&(this.removeHandles(a.uid),this._buildActiveLayerInfo(a))}_isLayerActive(a){return this.respectLayerVisibility?a.legendEnabled&&a.layer?.legendEnabled:!0}_buildActiveLayerInfo(a){const b=a.layer,d=a.uid;var f=this._layerInfosByLayerViewId[d];
let c=this._activeLayerInfosByLayerViewId[d];c||(c=new r({layer:b,layerView:a,title:void 0!==f?.title&&f.layer.uid===b.uid?f.title:b.title,view:this.view??void 0,respectLayerDefinitionExpression:this.respectLayerDefinitionExpression,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:f?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[d]=c);c.parent=this._activeLayerInfosByLayerViewId[(b.parent&&
"uid"in b.parent?this._layerViewByLayerId[b.parent?.uid]:null)?.uid];if(!this.hasHandles(d)){f=g.watch(()=>b.title,n=>this._titleHandle(n,c));var e=g.watch(()=>[b.opacity,"renderer"in b&&b.renderer,"pointSymbol"in b&&b.pointSymbol,"lineSymbol"in b&&b.lineSymbol,"polygonSymbol"in b&&b.polygonSymbol],()=>this._constructLegendElements(c)),m=g.when(()=>!0===this.view?.stationary,()=>this._scaleHandle(c),g.initial);const A=g.watch(()=>a.layer?q.getEffectiveFeatureReduction(a.layer,a.view):null,()=>this._constructLegendElements(c)),
B=g.watch(()=>a.updating,()=>{null!=a.layer&&null!=q.getEffectiveFeatureReduction(a.layer,a.view)&&this._constructLegendElements(c)}),C=g.watch(()=>"effect"in b&&b.effect,()=>this._constructLegendElements(c)),D=g.when(()=>this.view?.timeZone,()=>this._constructLegendElements(c),g.initial);f=[f,e,m,A,B,C,D];this.respectLayerVisibility&&(e=g.watch(()=>a.legendEnabled,n=>this._legendEnabledHandle(n,c)),m=g.watch(()=>b.legendEnabled,n=>this._legendEnabledHandle(n,c)),f.push(e,m));this.addHandles(f,d)}c.isScaleDriven||
this._constructLegendElements(c);this._addActiveLayerInfo(c)}_titleHandle(a,b){b.title=a;this._constructLegendElements(b)}_legendEnabledHandle(a,b){a?this._addActiveLayerInfo(b):this._removeActiveLayerInfo(b)}_scaleHandle(a){(a.isScaleDriven||a.hideLayersNotInCurrentView)&&this._constructLegendElements(a)}_addActiveLayerInfo(a){const {layerView:b,layer:d}=a;if(this._isLayerActive(b)&&!this.activeLayerInfos.includes(a)){var f=a.parent;f?(f.children.includes(a)||f.children.push(a),this._sortActiveLayerInfos(f.children)):
(f=this.layerInfos?.some(c=>c.layer.uid===d.uid),d.parent&&"uid"in d.parent&&!f?this._activeLayerInfosWithNoParent.add(a):(this.activeLayerInfos.add(a),this._sortActiveLayerInfos(this.activeLayerInfos)));if(this._activeLayerInfosWithNoParent.length){const c=[];this._activeLayerInfosWithNoParent.forEach(e=>{var m=e.layer.parent;if(m=this._activeLayerInfosByLayerViewId[(m&&"uid"in m?this._layerViewByLayerId[m?.uid]:null)?.uid])c.push(e),e.parent=m});c.length&&(this._activeLayerInfosWithNoParent.removeMany(c),
c.forEach(e=>this._addActiveLayerInfo(e)))}}}_removeActiveLayerInfo(a){const b=a.parent;b?b.children.remove(a):this.activeLayerInfos.remove(a)}_constructLegendElements(a){const b=a.layer;"featureCollections"in b&&b.featureCollections?a.buildLegendElementsForFeatureCollections(b.featureCollections):"featureReduction"in b&&b.featureReduction&&"renderer"in b.featureReduction&&("binning"===b.featureReduction.type||"cluster"===b.featureReduction.type)&&(!this.view||b.featureReduction.maxScale<=this.view.scale)?
a.buildLegendElementsForFeatureReduction(b.featureReduction):"renderer"in b&&b.renderer&&!("sublayers"in b)?a.buildLegendElementsForRenderer(b.renderer):"url"in b&&b.url&&"catalog"!==b.type?a.buildLegendElementsForTools():a.children.forEach(d=>this._constructLegendElements(d))}};k.__decorate([l.property({type:t})],h.prototype,"activeLayerInfos",void 0);k.__decorate([l.property()],h.prototype,"basemapLegendVisible",void 0);k.__decorate([l.property()],h.prototype,"groundLegendVisible",void 0);k.__decorate([l.property()],
h.prototype,"hideLayersNotInCurrentView",void 0);k.__decorate([l.property()],h.prototype,"keepCacheOnDestroy",void 0);k.__decorate([l.property()],h.prototype,"respectLayerDefinitionExpression",void 0);k.__decorate([l.property()],h.prototype,"respectLayerVisibility",void 0);k.__decorate([l.property()],h.prototype,"layerInfos",void 0);k.__decorate([l.property({readOnly:!0})],h.prototype,"state",null);k.__decorate([l.property()],h.prototype,"view",void 0);return h=k.__decorate([v.subclass("esri.widgets.Legend.LegendViewModel")],
h)});