ArcGISMapService.js 3.7 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.25/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../request.js";import{throwIfAborted as s}from"../../core/promiseUtils.js";import{urlToObject as t}from"../../core/urlUtils.js";import{Version as o}from"../../core/Version.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../geometry/Extent.js";import n from"../../geometry/SpatialReference.js";import{id as u,popupEnabled as c}from"../support/commonProperties.js";const y=y=>{let d=class extends y{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesPromise=null,this._allLayersAndTablesMap=null}readCapabilities(e,r){const s=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!s)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};const t=this.type,i=s.includes("data"),p=s.includes("query"),a=s.includes("map"),l=!!r.exportTilesAllowed,n=s.includes("tilemap"),u="tile"!==t&&!!r.supportsDynamicLayers,c="tile"!==t&&(!r.tileInfo||u),y="tile"!==t&&(!r.tileInfo||u),d="tile"!==t,m=r.cimVersion&&o.parse(r.cimVersion),h=m?.since(1,4)??!1,b=m?.since(2,0)??!1;return{operations:{supportsExportMap:a,supportsExportTiles:l,supportsIdentify:p,supportsQuery:i,supportsTileMap:n},exportMap:a?{supportsArcadeExpressionForLabeling:h,supportsSublayersChanges:d,supportsDynamicLayers:u,supportsSublayerVisibility:c,supportsSublayerDefinitionExpression:y,supportsCIMSymbols:b}:null,exportTiles:l?{maxExportTilesCount:+r.maxExportTilesCount}:null}}readVersion(e,r){let s=r.currentVersion;return s||(s=r.hasOwnProperty("capabilities")||r.hasOwnProperty("tables")?10:r.hasOwnProperty("supportedImageFormatTypes")?9.31:9.3),s}async fetchSublayerInfo(e,r){return await this.fetchAllLayersAndTables(r),this._allLayersAndTablesMap?.get(e)}async fetchAllLayersAndTables(e){await this.load(e),this._allLayersAndTablesPromise||(this._allLayersAndTablesPromise=r(t(this.url).path+"/layers",{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey}}).then((e=>{this._allLayersAndTablesMap=new Map;for(const r of e.data.layers)this._allLayersAndTablesMap.set(r.id,r);return{result:e.data}}),(e=>({error:e}))));const o=await this._allLayersAndTablesPromise;if(s(e),"result"in o)return o.result;throw o.error}};return e([i({readOnly:!0})],d.prototype,"capabilities",void 0),e([p("service","capabilities",["capabilities","exportTilesAllowed","maxExportTilesCount","supportsDynamicLayers","tileInfo"])],d.prototype,"readCapabilities",null),e([i({json:{read:{source:"copyrightText"}}})],d.prototype,"copyright",void 0),e([i({type:l})],d.prototype,"fullExtent",void 0),e([i(u)],d.prototype,"id",void 0),e([i({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend"}}})],d.prototype,"legendEnabled",void 0),e([i(c)],d.prototype,"popupEnabled",void 0),e([i({type:n})],d.prototype,"spatialReference",void 0),e([i({readOnly:!0})],d.prototype,"version",void 0),e([p("version",["currentVersion","capabilities","tables","supportedImageFormatTypes"])],d.prototype,"readVersion",null),d=e([a("esri.layers.mixins.ArcGISMapService")],d),d};export{y as ArcGISMapService};