@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.46 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../request.js";import r from"../core/Error.js";import{EventedMixin as o}from"../core/Evented.js";import{IdentifiableMixin as i}from"../core/Identifiable.js";import{Loadable as a}from"../core/Loadable.js";import l from"../core/Logger.js";import{isAbortError as n}from"../core/promiseUtils.js";import{urlToObject as s}from"../core/urlUtils.js";import{property as p,subclass as y}from"../core/accessorSupport/decorators.js";import d from"../geometry/Extent.js";import u from"../geometry/SpatialReference.js";import{fromPortalItem as m}from"./support/fromPortalItem.js";import h from"../time/TimeExtent.js";let c=0,b=class extends(o(i(a))){constructor(){super(...arguments),this.attributionDataUrl=null,this.fullExtent=new d(-180,-90,180,90,u.WGS84),this.id=Date.now().toString(16)+"-layer-"+c++,this.legendEnabled=!0,this.listMode="show",this.opacity=1,this.parent=null,this.persistenceEnabled=!1,this.popupEnabled=!0,this.attributionVisible=!0,this.spatialReference=u.WGS84,this.title=null,this.type=null,this.url=null,this.visibilityTimeExtent=null,this.visible=!0}static async fromArcGISServerUrl(t){const e="string"==typeof t?{url:t}:t;return(await import("./support/arcgisLayers.js")).fromUrl(e)}static fromPortalItem(t){return m(t)}initialize(){this.when().catch(t=>{n(t)||l.getLogger(this).error("#load()",`Failed to load layer (title: '${this.title??"no title"}', id: '${this.id??"no id"}')`,{error:t})})}destroy(){const{parent:t}=this;t&&(this.parent=null,t.removeChildLayer?.(this))}get effectiveVisible(){return this.visible&&(this.parent?.effectiveVisible??!0)}get hasAttributionData(){return null!=this.attributionDataUrl}get loaded(){return super.loaded}removeFromParent(){const{parent:t}=this;t&&(t.removeChildLayer?.(this),this.parent=null)}get parsedUrl(){return s(this.url)}createLayerView(t,e){return Promise.reject(new r("layer:create-layer-view","Layer does not support creating a layer view"))}async fetchAttributionData(){const t=this.attributionDataUrl;if(this.hasAttributionData&&t){return(await e(t,{query:{f:"json"},responseType:"json"})).data}throw new r("layer:no-attribution-data","Layer does not have attribution data")}};t([p({type:String})],b.prototype,"attributionDataUrl",void 0),t([p({readOnly:!0})],b.prototype,"effectiveVisible",null),t([p({type:d})],b.prototype,"fullExtent",void 0),t([p({readOnly:!0})],b.prototype,"hasAttributionData",null),t([p({type:String,clonable:!1})],b.prototype,"id",void 0),t([p({type:Boolean,nonNullable:!0})],b.prototype,"legendEnabled",void 0),t([p({type:["show","hide","hide-children"]})],b.prototype,"listMode",void 0),t([p({type:Number,range:{min:0,max:1},nonNullable:!0})],b.prototype,"opacity",void 0),t([p({clonable:!1})],b.prototype,"parent",void 0),t([p({readOnly:!0})],b.prototype,"parsedUrl",null),t([p({type:Boolean,readOnly:!0})],b.prototype,"persistenceEnabled",void 0),t([p({type:Boolean})],b.prototype,"popupEnabled",void 0),t([p({type:Boolean})],b.prototype,"attributionVisible",void 0),t([p({type:u})],b.prototype,"spatialReference",void 0),t([p({type:String})],b.prototype,"title",void 0),t([p({readOnly:!0,json:{read:!1}})],b.prototype,"type",void 0),t([p()],b.prototype,"url",void 0),t([p({type:h})],b.prototype,"visibilityTimeExtent",void 0),t([p({type:Boolean,nonNullable:!0})],b.prototype,"visible",void 0),b=t([y("esri.layers.Layer")],b);export{b as default};