UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.79 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as t}from"tslib";import{equals as e}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import{EventedAccessor as r}from"../../core/Evented.js";import{IdentifiableMixin as s}from"../../core/Identifiable.js";import n from"../../core/Logger.js";import{destroyMaybe as a,removeMaybe as l}from"../../core/maybe.js";import{EsriPromiseMixin as o}from"../../core/Promise.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import{property as p,subclass as d}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{getAttributionItemFromUserCopyright as y,isDynamicAttributionLayer as c,createAttributionIndex as g,getAttributionItemsFromIndex as m,getAttributionItemFromAccessInformation as b,getAttributionItemFromLayerCopyright as f}from"../support/attributionUtils.js";import{validateScaleRange as v}from"../support/layerViewUtils.js";let I=class extends(s(o(r))){get spatialReferenceSupported(){return!0}constructor(t){super(t),this._updatingHandles=new h,this._attributionIndexTask=null,this.layer=null,this.parent=null}initialize(){this.when().catch(t=>{if("layerview:create-error"!==t.name){const e=this.layer&&this.layer.id||"no id",i=this.layer?.title||"no title";n.getLogger(this).error("#resolve()",`Failed to resolve layer view (layer title: '${i}', id: '${e}')`,t)}})}destroy(){this._updatingHandles=a(this._updatingHandles),this._attributionIndexTask=l(this._attributionIndexTask),this._set("parent",null)}get attributionItems(){const t=this._get("attributionItems")??[];if(this.suspended||!this.layer?.attributionVisible)return 0===t.length?t:[];if(!this.view.stationary)return t;const i=this.getAttributionItems();return e(t,i,(t,e)=>t.text===e.text)?t:i}get attributionUpdating(){return!!this._attributionIndexTask&&!this._attributionIndexTask.finished}get fullOpacity(){return(this.layer?.opacity??1)*(this.parent?.fullOpacity??1)}get suspended(){return this.destroyed||!this.canResume()}get suspendInfo(){return this.getSuspendInfo()}get legendEnabled(){return!this.suspended&&!0===this.layer?.legendEnabled}get updating(){return!(!this._updatingHandles?.updating&&!this.isUpdating())}get updatingProgress(){return this.updating?0:1}get updateSuspended(){return this.suspended}get visible(){return!0===this.layer?.visible}set visible(t){this._overrideIfSome("visible",t)}get visibleAtCurrentScale(){return!0}get visibleAtCurrentTimeExtent(){const t=this.view.timeExtent,e=this.layer?.visibilityTimeExtent;return!t||!e||!t.intersection(e).isEmpty}canResume(){const t=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&v(t)&&this.visibleAtCurrentScale&&this.visibleAtCurrentTimeExtent||!1}getSuspendInfo(){const t=this.parent?.suspended?this.parent.suspendInfo:{},e=this;e.view?.ready||(t.viewNotReady=!0),this.layer&&this.layer.loaded||(t.layerNotLoaded=!0);const i=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return v(i)&&this.visibleAtCurrentScale||(t.outsideScaleRange=!0),this.visibleAtCurrentTimeExtent||(t.outsideVisibilityTimeExtent=!0),this.visible||(t.layerInvisible=!0),t}isUpdating(){return!1}getAttributionItems(){const t=y(this.layer);if(t)return[t];if(c(this.layer)&&(this._attributionIndexTask||(this._attributionIndexTask=i(async t=>{const e=await this.layer.fetchAttributionData();return u(t),g(e)}),this._updatingHandles.addPromise(this._attributionIndexTask.promise)),this._attributionIndexTask?.finished&&this._attributionIndexTask.value))return m(this._attributionIndexTask.value,this.layer.tileInfo,this.view.scale,this.view.extent);const e=b(this.layer);if(e)return[e];const r=f(this.layer);return r?[r]:[]}};t([p({readOnly:!0})],I.prototype,"spatialReferenceSupported",null),t([p()],I.prototype,"view",void 0),t([p({readOnly:!0})],I.prototype,"attributionItems",null),t([p({readOnly:!0})],I.prototype,"attributionUpdating",null),t([p()],I.prototype,"fullOpacity",null),t([p()],I.prototype,"layer",void 0),t([p()],I.prototype,"parent",void 0),t([p({readOnly:!0})],I.prototype,"suspended",null),t([p({readOnly:!0})],I.prototype,"suspendInfo",null),t([p({readOnly:!0})],I.prototype,"legendEnabled",null),t([p({type:Boolean,readOnly:!0})],I.prototype,"updating",null),t([p({readOnly:!0})],I.prototype,"updatingProgress",null),t([p()],I.prototype,"updateSuspended",null),t([p()],I.prototype,"visible",null),t([p({readOnly:!0})],I.prototype,"visibleAtCurrentScale",null),t([p({readOnly:!0})],I.prototype,"visibleAtCurrentTimeExtent",null),I=t([d("esri.views.layers.LayerView")],I);export{I as default};