@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 9 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import{MultiOriginJSONSupportMixin as r}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as i}from"../core/promiseUtils.js";import{urlToObject as o}from"../core/urlUtils.js";import{property as s,subclass as p}from"../core/accessorSupport/decorators.js";import n from"../geometry/Extent.js";import a from"../geometry/SpatialReference.js";import{featureGeometryTypeKebabDictionary as l}from"../geometry/support/typeUtils.js";import u from"../graphic/GeoJSONGraphicOrigin.js";import m from"./Layer.js";import{GeoJSONSource as d}from"./graphics/sources/GeoJSONSource.js";import{BlendLayer as y}from"./mixins/BlendLayer.js";import{CustomParametersMixin as f}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as h}from"./mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as c}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as g}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{OrderedLayer as v}from"./mixins/OrderedLayer.js";import{PortalLayer as b}from"./mixins/PortalLayer.js";import{RefreshableLayer as x}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as O}from"./mixins/TemporalLayer.js";import{TrackableLayer as T}from"./mixins/TrackableLayer.js";import{attributeTableTemplate as E,elevationInfo as F,id as w,labelsVisible as S,legendEnabled as P,opacity as L,popupEnabled as q,screenSizePerspectiveEnabled as J,url as N}from"./support/commonProperties.js";import{validateBinsQuery as U}from"./support/featureLayerUtils.js";import D from"./support/FeatureTemplate.js";import G from"./support/Field.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{fixRendererFields as R,fixTimeInfoFields as B}from"./support/fieldUtils.js";import Z from"./support/LabelClass.js";import{reader as C}from"./support/labelingInfo.js";import{webSceneRendererTypes as V,rendererTypes as _}from"../renderers/support/typeUtils.js";import A from"../rest/support/Query.js";import{createPopupTemplate as M}from"../support/popupUtils.js";import z from"../time/TimeExtent.js";import k from"../time/TimeInterval.js";import{timeZoneProperty as W}from"../time/timeZoneUtils.js";const H=Q();let K=class extends(v(h(f(g(c(y(O(T(I(x(j(b(r(m)))))))))))))){constructor(e){super(e),this.attributeTableTemplate=null,this.copyright=null,this.dateFieldsTimeZone=null,this.definitionExpression=null,this.displayField=null,this.editingEnabled=!1,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.fullExtent=null,this.geometryType=null,this.graphicOrigin=new u(this),this.hasZ=void 0,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.objectIdField=null,this.operationalLayerType="GeoJSON",this.outFields=null,this.popupEnabled=!0,this.popupTemplate=null,this.screenSizePerspectiveEnabled=!0,this.source=new d({layer:this}),this.spatialReference=a.WGS84,this.templates=null,this.title="GeoJSON",this.type="geojson"}destroy(){this.source?.destroy()}load(e){const t=this.loadFromPortal({supportedTypes:["GeoJson"],supportsData:!1},e).catch(i).then(()=>this.source.load(e)).then(()=>{this.read(this.source.sourceJSON,{origin:"service",url:this.parsedUrl}),["objectIdField","fields","timeInfo"].forEach(e=>this.revertToOrigin(e,"service")),R(this.renderer,this.fieldsIndex),B(this.timeInfo,this.fieldsIndex)});return this.addResolvingPromise(t),Promise.resolve(this)}get portalItem(){return super.portalItem}set portalItem(e){super.portalItem=e}get timeInfo(){return super.timeInfo}set timeInfo(e){super.timeInfo=e}get capabilities(){return this.source?this.source.capabilities:null}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("capabilities"),(this._get("createQueryVersion")||0)+1}get defaultPopupTemplate(){return this.createPopupTemplate()}get isTable(){return this.loaded&&null==this.geometryType}get parsedUrl(){return o(this.url)}set renderer(e){R(e,this.fieldsIndex),this._set("renderer",e)}set url(e){if(!e)return void this._set("url",e);const t=o(e);this._set("url",t.path),t.query&&(this.customParameters={...this.customParameters,...t.query})}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");await this.load();const i=await r(this,this.source,e,t);return this.read({extent:this.source.sourceJSON.extent,timeInfo:this.source.sourceJSON.timeInfo},{origin:"service",ignoreDefaults:!0}),i}createPopupTemplate(e){return M(this,e)}createQuery(){const e=new A,t=this.capabilities?.data;e.returnGeometry=!0,t&&t.supportsZ&&(e.returnZ=!0),e.outFields=["*"],e.where=this.definitionExpression||"1=1";const{timeOffset:r,timeExtent:i}=this;return e.timeExtent=null!=r&&null!=i?i.offset(-r.value,r.unit):i||null,e}getFieldDomain(e,t){return this.getField(e)?.domain}getField(e){return this.fieldsIndex.get(e)}queryFeatures(e,t){return this.load().then(()=>this.source.queryFeatures(A.from(e)||this.createQuery(),t)).then(e=>{if(e?.features)for(const t of e.features)t.layer=t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}queryObjectIds(e,t){return this.load().then(()=>this.source.queryObjectIds(A.from(e)||this.createQuery(),t))}queryFeatureCount(e,t){return this.load().then(()=>this.source.queryFeatureCount(A.from(e)||this.createQuery(),t))}queryExtent(e,t){return this.load().then(()=>this.source.queryExtent(A.from(e)||this.createQuery(),t))}async queryAttributeBins(e,t){const{source:r,capabilities:i}=await this.load();U(e,i,"GeoJSONLayer");const o=await import("../rest/support/AttributeBinsQuery.js"),s=await r.queryAttributeBins(o.default.from(e),t);if(s.features)for(const p of s.features)p.layer=p.sourceLayer=this;return s}async hasDataChanged(){try{const{dataChanged:e,updates:t}=await this.source.refresh(this.customParameters);return null!=t&&this.read(t,{origin:"service",url:this.parsedUrl,ignoreDefaults:!0}),e}catch{}return!1}};e([s({type:z})],K.prototype,"timeExtent",void 0),e([s({type:k})],K.prototype,"timeOffset",void 0),e([s(E)],K.prototype,"attributeTableTemplate",void 0),e([s({readOnly:!0,json:{read:!1,write:!1}})],K.prototype,"capabilities",null),e([s({type:String})],K.prototype,"copyright",void 0),e([s({readOnly:!0})],K.prototype,"createQueryVersion",null),e([s(W("dateFieldsTimeReference"))],K.prototype,"dateFieldsTimeZone",void 0),e([s({readOnly:!0})],K.prototype,"defaultPopupTemplate",null),e([s({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],K.prototype,"definitionExpression",void 0),e([s({type:String})],K.prototype,"displayField",void 0),e([s({type:Boolean})],K.prototype,"editingEnabled",void 0),e([s(F)],K.prototype,"elevationInfo",void 0),e([s({type:[G],json:{name:"layerDefinition.fields",write:{ignoreOrigin:!0,isRequired:!0},origins:{service:{name:"fields"}}}})],K.prototype,"fields",void 0),e([s(H.fieldsIndex)],K.prototype,"fieldsIndex",void 0),e([s({type:n,json:{name:"extent"}})],K.prototype,"fullExtent",void 0),e([s({type:["point","polygon","polyline","multipoint"],json:{read:{reader:l.read}}})],K.prototype,"geometryType",void 0),e([s({readOnly:!0,clonable:!1})],K.prototype,"graphicOrigin",void 0),e([s({type:Boolean})],K.prototype,"hasZ",void 0),e([s(w)],K.prototype,"id",void 0),e([s({type:Boolean,readOnly:!0})],K.prototype,"isTable",null),e([s(S)],K.prototype,"labelsVisible",void 0),e([s({type:[Z],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:C},write:!0}})],K.prototype,"labelingInfo",void 0),e([s(P)],K.prototype,"legendEnabled",void 0),e([s({type:["show","hide"]})],K.prototype,"listMode",void 0),e([s({type:String,json:{name:"layerDefinition.objectIdField",write:{ignoreOrigin:!0,isRequired:!0},origins:{service:{name:"objectIdField"}}}})],K.prototype,"objectIdField",void 0),e([s(L)],K.prototype,"opacity",void 0),e([s({type:["GeoJSON"]})],K.prototype,"operationalLayerType",void 0),e([s(H.outFields)],K.prototype,"outFields",void 0),e([s({readOnly:!0})],K.prototype,"parsedUrl",null),e([s(q)],K.prototype,"popupEnabled",void 0),e([s({type:t,json:{name:"popupInfo",write:!0}})],K.prototype,"popupTemplate",void 0),e([s({types:_,json:{name:"layerDefinition.drawingInfo.renderer",write:!0,origins:{service:{name:"drawingInfo.renderer"},"web-scene":{types:V}}}})],K.prototype,"renderer",null),e([s(J)],K.prototype,"screenSizePerspectiveEnabled",void 0),e([s({readOnly:!0})],K.prototype,"source",void 0),e([s({type:a})],K.prototype,"spatialReference",void 0),e([s({type:[D]})],K.prototype,"templates",void 0),e([s()],K.prototype,"title",void 0),e([s({json:{read:!1},readOnly:!0})],K.prototype,"type",void 0),e([s(N)],K.prototype,"url",null),K=e([p("esri.layers.GeoJSONLayer")],K);const X=K;export{X as default};