@vertigis/arcgis-extensions 35.0.5 → 35.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppConfig.schema.json +4 -0
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/data_FeatureStream.FeatureStream.html +1 -1
- package/docs/html/classes/mapping_ArcGISSublayerExtension.ArcGISSublayerExtension.html +24 -21
- package/docs/html/classes/mapping_ArcGISSublayerExtension.ArcGISSublayerSchema.html +1 -1
- package/docs/html/classes/mapping_BasemapExtension.BasemapExtension.html +24 -22
- package/docs/html/classes/mapping_BuildingComponentSublayerExtension.BuildingComponentSublayerExtension.html +22 -19
- package/docs/html/classes/mapping_BuildingComponentSublayerExtension.BuildingComponentSublayerSchema.html +1 -1
- package/docs/html/classes/mapping_BuildingGroupSublayerExtension.BuildingGroupSublayerExtension.html +26 -23
- package/docs/html/classes/mapping_BuildingGroupSublayerExtension.BuildingGroupSublayerSchema.html +2 -2
- package/docs/html/classes/mapping_BuildingSceneLayerExtension.BuildingSceneLayerExtension.html +34 -31
- package/docs/html/classes/mapping_BuildingSceneLayerExtension.BuildingSceneLayerReadOnlySchema.html +3 -3
- package/docs/html/classes/mapping_BuildingSublayerExtension.BuildingSublayerExtension.html +31 -28
- package/docs/html/classes/mapping_BuildingSublayerExtension.BuildingSublayerSchema.html +2 -2
- package/docs/html/classes/mapping_CSVLayerExtension.CSVLayerExtension.html +40 -40
- package/docs/html/classes/mapping_ElevationLayerExtension.ElevationLayerExtension.html +37 -34
- package/docs/html/classes/mapping_FeatureCollectionLayerExtension.FeatureCollectionLayerExtension.html +34 -31
- package/docs/html/classes/mapping_FeatureLayerExtension.FeatureLayerExtension.html +45 -45
- package/docs/html/classes/mapping_FeatureLayerExtensionBase.FeatureLayerExtensionBase.html +37 -34
- package/docs/html/classes/mapping_FeatureLayerExtensionBase.FeatureLayerSchema.html +4 -4
- package/docs/html/classes/mapping_GeoRSSLayerExtension.GeoRSSLayerExtension.html +37 -34
- package/docs/html/classes/mapping_GraphicsLayerExtension.GraphicsLayerExtension.html +33 -30
- package/docs/html/classes/mapping_GroupLayerExtension.GroupLayerExtension.html +34 -31
- package/docs/html/classes/mapping_ImageryLayerExtension.ImageryLayerExtension.html +37 -34
- package/docs/html/classes/mapping_ImageryTileLayerExtension.ImageryTileLayerExtension.html +35 -32
- package/docs/html/classes/mapping_IntegratedMeshLayerExtension.IntegratedMeshLayerExtension.html +38 -35
- package/docs/html/classes/mapping_KMLLayerExtension.KMLLayerExtension.html +35 -32
- package/docs/html/classes/mapping_KMLSublayerExtension.KMLSublayerExtension.html +28 -25
- package/docs/html/classes/mapping_MapImageLayerExtension.MapImageLayerExtension.html +36 -33
- package/docs/html/classes/mapping_MapImageSublayerExtension.MapImageSublayerExtension.html +22 -22
- package/docs/html/classes/mapping_OpenStreetMapLayerExtension.OpenStreetMapLayerExtension.html +39 -36
- package/docs/html/classes/mapping_PointCloudLayerExtension.PointCloudLayerExtension.html +37 -34
- package/docs/html/classes/mapping_SceneLayerExtension.SceneLayerExtension.html +40 -40
- package/docs/html/classes/mapping_StreamLayerExtension.StreamLayerExtension.html +40 -40
- package/docs/html/classes/mapping_StreamLayerExtension.StreamLayerSchema.html +7 -7
- package/docs/html/classes/mapping_TileLayerExtension.TileLayerExtension.html +33 -30
- package/docs/html/classes/mapping_TileSublayerExtension.TileSublayerExtension.html +23 -20
- package/docs/html/classes/mapping_UnsupportedLayerExtension.UnsupportedLayerExtension.html +38 -35
- package/docs/html/classes/mapping_VectorTileLayerExtension.VectorTileLayerExtension.html +36 -33
- package/docs/html/classes/mapping_WMSLayerExtension.WMSLayerExtension.html +35 -32
- package/docs/html/classes/mapping_WMSSublayerExtension.WMSSublayerExtension.html +27 -24
- package/docs/html/classes/mapping_WMTSLayerExtension.WMTSLayerExtension.html +34 -31
- package/docs/html/classes/mapping_WMTSSublayerExtension.WMTSSublayerExtension.html +28 -25
- package/docs/html/classes/mapping_WebTileLayerExtension.WebTileLayerExtension.html +39 -36
- package/docs/html/classes/mapping__LayerExtension.ArrayWrappedCollection.html +2 -2
- package/docs/html/classes/mapping__LayerExtension.LayerExtension.html +41 -38
- package/docs/html/classes/mapping__LayerExtension.LayerExtensionSchema.html +5 -5
- package/docs/html/classes/mapping__SublayerExtension.SubSublayerExtensionCollection.html +6 -6
- package/docs/html/classes/mapping__SublayerExtension.SublayerExtension.html +34 -31
- package/docs/html/classes/mapping__SublayerExtension.SublayerSchema.html +2 -2
- package/docs/html/classes/menus_MenuItem.MenuItem.html +3 -3
- package/docs/html/classes/utilities_asyncIterable.AsyncQueue.html +1 -1
- package/docs/html/interfaces/mapping_BasemapExtension.BasemapExtensionProperties.html +9 -7
- package/docs/html/interfaces/portal_DrawingInfo.DrawingInfo-1.html +7 -7
- package/docs/html/modules/mapping__LayerExtension.html +1 -1
- package/docs/html/modules/portal_DrawingInfo.DrawingInfo.html +3 -3
- package/docs/html/modules/version.html +1 -1
- package/mapping/BasemapExtension.d.ts +8 -0
- package/mapping/BasemapExtension.js +1 -1
- package/mapping/CSVLayerExtension.d.ts +4 -0
- package/mapping/CSVLayerExtension.js +1 -1
- package/mapping/FeatureLayerExtension.d.ts +4 -0
- package/mapping/FeatureLayerExtension.js +1 -1
- package/mapping/MapImageSublayerExtension.d.ts +4 -0
- package/mapping/MapImageSublayerExtension.js +1 -1
- package/mapping/SceneLayerExtension.d.ts +4 -0
- package/mapping/SceneLayerExtension.js +1 -1
- package/mapping/StreamLayerExtension.d.ts +4 -0
- package/mapping/StreamLayerExtension.js +1 -1
- package/mapping/_LayerExtension.d.ts +5 -0
- package/mapping/_LayerExtension.js +1 -1
- package/mapping/_SublayerExtension.d.ts +5 -0
- package/mapping/_SublayerExtension.js +1 -1
- package/menus/MenuItem.d.ts +1 -1
- package/package.json +1 -1
- package/portal/DrawingInfo.d.ts +3 -1
- package/portal/DrawingInfo.js +1 -1
- package/tasks/geocoding/ArcGISGeocoder.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{ArgumentError}from"../ArgumentError.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{FeatureSourceBase}from"../data/FeatureSourceBase.js";import{Schema}from"../data/Schema.js";import{LayerBase as PortalLayerBase}from"../portal/LayerBase.js";import{ERR_LAYER_TYPE_MISMATCH}from"../portal/_layerHelper.js";import{DefaultArcGISRequestHelper}from"../support/ArcGISRequestHelper.js";import{ReadOnlyInitializableCollection}from"../support/ReadOnlyInitializableCollection.js";import{serializable}from"../support/Serializable.js";import{CollectionProxy}from"../utilities/CollectionProxy.js";import{isLayer}from"../utilities/_layers.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{load}from"../utilities/esri.js";import{isGroupLayerExtension}from"../utilities/extensions.js";import{hasMmapLayer}from"../utilities/layers.js";import{getLogger}from"../utilities/log.js";import{deepClone}from"../utilities/object.js";import{toPortalItem}from"../utilities/portal.js";import{onCollectionPropertyChange,watchEach}from"../utilities/watch.js";import{_assignSublayerExtensions}from"./_SublayerExtension.js";import{ExtensionBaseLayerListSettings,fromLayerListMode}from"./support/LayerListSettings.js";import{SublayerExtensionCollectionBase}from"./support/_SublayerExtensionCollection.js";const ERR_INVALID_LAYER_TYPE="Invalid type of layer for this type of layer extension.",ERR_FEATURES_NOT_SUPPORTED="This type of layer does not have features.",ERR_ADD_SUBLAYERX_NOT_SUPPORTED="This type of layer cannot have sublayers.",ERR_SCHEMA_READ_ONLY="This schema property is read-only.",DEFAULT_CAPABILITIES=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1});export class LayerExtension extends FeatureSourceBase{constructor(e){super(e),this._itemType=ItemType.LAYER_EXTENSION,this._watchHandles=[],this._dynamicallyAddedLayer=!1,this._visibilityMode="independent",this._onSublayerAddedPostInitialize=async e=>{try{await e.initialize()}catch(t){getLayerXLogger().error({message:`Error occurred while initializing sublayer extension for sublayer '${e.title??e.sublayer.id??e.id}'.`,error:t})}},this._onVisibleChanged=e=>{if("inherited"===this.visibilityMode&&this.supportsSublayers&&this._sublayers)for(const t of this._sublayers.toArray())t.visible=e;this.notifyChange("isEffectivelyVisible")},this._onSublayersSublayerVisibleChanged=(e,t,i,r)=>{e&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(r)},this._onSublayersChange=e=>{e.added?.length&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(e.added[e.added.length-1])};const t={...this.getDefaults(),...e};checkArg("properties.layer",t.layer).isNotMissing();const{layer:i}=t;let r;if(i?.hasOwnProperty("listMode")&&(r=fromLayerListMode(i.listMode)),this.layerListSettings=this._createLayerListSettings({...r,...t.layerListSettings}),isLayer(i))checkArg("properties.layer",i).satisfies((e=>this._isSupportedLayer(e)),ERR_INVALID_LAYER_TYPE),this._setLayer(i);else if(i){if(i.$portalItem){const e=i.$portalItem;this._portalItem=toPortalItem(e)}this._deferredLayerProperties=i}this._sublayerExtensions=this._createSublayerExtensionCollection(),this.allSublayerExtensions=new AllSublayerExtensionCollectionImpl(this),this.watch("parentLayerExtension.isEffectivelyVisible",(()=>this.notifyChange("isEffectivelyVisible"))),this.watch("layer.sublayers",(()=>this.notifyChange("_sublayers")))}get layer(){return this._layer}get mapExtension(){return this._mapExtension}get basemapExtension(){return this._basemapExtension}get groundExtension(){return this._groundExtension}get parentLayerExtension(){return this._parentLayerExtension}get hasFeatures(){return!1}get capabilities(){return this._capabilities()}get renderer(){}get visibilityMode(){return this._visibilityMode}set visibilityMode(e){this._visibilityMode=e,"exclusive"===e&&this._ensureAtMostOneChildSublayerVisible()}get sublayerExtensions(){return this._sublayerExtensions}get requestHelper(){return this._requestHelper||(this._requestHelper=new DefaultArcGISRequestHelper),this._requestHelper}set requestHelper(e){this._requestHelper=e}get title(){return this.layer?.title??this._deferredLayerProperties?.title??("string"==typeof this._deferredLayerProperties?.$ref?this._deferredLayerProperties?.$ref:this._deferredLayerProperties?.$ref?.title??this._deferredLayerProperties?.$ref?.id)??"Layer"}get supportsSublayers(){return!1}get effectiveMinScale(){return this.layer&&this.layer.minScale||0}get effectiveMaxScale(){return this.layer&&this.layer.maxScale||0}get isEffectivelyVisible(){const e=!!this.layer&&this.layer.visible;return this.parentLayerExtension?this.parentLayerExtension.isEffectivelyVisible&&e:e}get effectiveFullExtent(){return this.layer?this.layer.fullExtent:void 0}get canChangeScale(){return!0}get canChangeOpacity(){return!0}get _layerSupportsHideChildren(){return this.supportsSublayers}get _sublayers(){if(this.supportsSublayers)return this.layer?this.layer.sublayers:void 0}get dynamicallyAddedLayer(){return this._dynamicallyAddedLayer}set dynamicallyAddedLayer(e){this._dynamicallyAddedLayer=e}static create(e){if(!LayerExtension.factory)throw new InvalidOperationError("Cannot create layer extension: no layer extension factory has been registered.");return LayerExtension.factory.create(e)}static async fromPortalItem(e,t){checkArg("portalItemLike",e).isNotMissing();const i=t??{};checkArg("layerExtensionProperties.layer",i.layer).satisfies((e=>!isLayer(e)));const r={...i.layer};checkArg("layerExtensionProperties.layer.$ref",r.$ref).satisfies((e=>null==e));const s=new DefaultArcGISRequestHelper,a=toPortalItem(e);let n;await load(a);const o=a.typeKeywords??"";if("Map Service"===a.type)n=o.includes("Tiled")||o.includes("Hosted Service")?"ArcGISTiledMapServiceLayer":"ArcGISMapServiceLayer";else if("Feature Service"===a.type)n="ArcGISFeatureLayer";else if("Image Service"===a.type){const e=await LayerExtension._getLayerData(a.url,s);e.cacheType?"Map"===e.cacheType?n="ArcGISTiledImageServiceLayer":("Elevation"===e.cacheType||o.includes("Elevation 3D Layer"))&&(n="ArcGISTiledElevationServiceLayer"):n=e.singleFusedMapCache||e.tileInfo||o.includes("Hosted Service")?"ArcGISTiledImageServiceLayer":"ArcGISImageServiceLayer"}else if("CSV"===a.type)n="CSV";else if("KML"===a.type)n="KML";else if("Scene Service"===a.type)o.includes("3DObject")||o.includes("Point")?n="ArcGISSceneServiceLayer":o.includes("IntegratedMesh")?n="IntegratedMeshLayer":o.includes("PointCloud")?n="PointCloudLayer":o.includes("Building")&&(n="BuildingSceneLayer");else if("Stream Service"===a.type)n="ArcGISStreamLayer";else if("Vector Tile Service"===a.type)n="VectorTileLayer";else if("Feature Collection"===a.type){n="ArcGISFeatureLayer";const e=await a.fetchData();r.featureCollection=e}else if("WMTS"===a.type){n="WebTiledLayer";const e=await a.fetchData();Object.assign(r,e)}else if("WMS"===a.type){n="WMS";const e=await a.fetchData();Object.assign(r,e)}if(!n)throw new ArgumentError("portalItem","Could not determine correct type of LayerExtension to create from portal item");if(r.layerType&&r.layerType!==n)throw new ArgumentError("layerExtensionProperties.layer.layerType","Layer type defined in layer properties does not match layer type from portal item");return r.layerType=n,r.$portalItem=a,i.layer=r,LayerExtension.create(i)}static _matchesRef(e,t){if(!e||!t)return!1;const i=t.$ref;return"string"==typeof i?e.id===i||e.title===i:!!i&&(e.id===i.id||e.title===i.title&&!i.path)}static async _getLayerData(e,t){const i=await t.request(e,{query:{f:"json"}});if(!i||!i.data)throw new Error(`Response to request for url ${e} was invalid.`);return i.data}getFeatures(e,t){if(!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);return super.getFeatures(e,t)}getFullExtent(){return this.effectiveFullExtent}async addFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.addFeatures(e,t)}async updateFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.updateFeatures(e,t)}async deleteFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.deleteFeatures(e,t)}async _createBackingLayer(){this._portalItem||this.layer||this._deferredLayerProperties&&this._deferredLayerProperties.$ref?!this.layer&&this._portalItem&&this._setLayer(await this._createLayer(this.getDefaults().layer)):(this._setLayer(await this._createLayer(this._deferredLayerProperties)),checkArg("properties.layer",this._layer).satisfies((e=>this._isSupportedLayer(e)),ERR_INVALID_LAYER_TYPE),this._deferredLayerProperties=void 0)}_setMapExtension(e){const t=this.mapExtension;this._mapExtension=e,t&&this.featureSettings.formatSettings.parent===t.formatSettings&&(this.featureSettings.formatSettings.parent=void 0),e&&(this.featureSettings.formatSettings.parent||(this.featureSettings.formatSettings.parent=e.formatSettings)),this._resolveLayer(),this.notifyChange("mapExtension")}_setBasemapExtension(e){this._basemapExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),this.notifyChange("basemapExtension")}_setGroundExtension(e){this._groundExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),this.notifyChange("groundExtension")}_setParentLayerExtension(e){const t=this._parentLayerExtension;this._parentLayerExtension=e,t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=this.mapExtension?this.mapExtension.formatSettings:void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=void 0)),e&&((!this.featureSettings.formatSettings.parent||this.mapExtension&&this.featureSettings.formatSettings.parent===this.mapExtension.formatSettings)&&(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),this.taskSettings.parent||(this.taskSettings.parent=e.taskSettings)),this._resolveLayer(),this.notifyChange("parentLayerExtension")}_resolveLayer(e){if(this.layer||!this._deferredLayerProperties)return;const t=e=>LayerExtension._matchesRef(e,this._deferredLayerProperties);let i;e?i=e.find(t):this.basemapExtension?.basemap?(i=this.basemapExtension.basemap.baseLayers.find(t),i=i||this.basemapExtension.basemap.referenceLayers.find(t)):this.groundExtension?.ground?i=this.groundExtension.ground.layers.find(t):this.parentLayerExtension?.layer?i=this.parentLayerExtension.layer.layers.find(t):this.mapExtension&&(i=this.mapExtension.map.layers.find(t)),i&&this._isSupportedLayer(i)&&(this._setLayer(i),this._originalRef=this._deferredLayerProperties.$ref,this._deferredLayerProperties.$portalItem&&getLayerXLogger().warn("LayerExtension defined with both $ref and $portalItem. Ignoring $portalItem."))}async _switchLayer(e){if(e===this.layer)return;checkArg("newLayer",e).isNotMissing().satisfies((e=>this._isSupportedLayer(e)),ERR_INVALID_LAYER_TYPE),this.isInitialized&&await load(e);const t=new Map;if(this._sublayers)for(const e of this._sublayers.toArray())t.set(e.id,this.sublayerExtensions.forSublayer(e));e.visible=this.layer.visible,e.opacity=this.layer.opacity,e.listMode=this.layer.listMode,this._setLayer(e);const i=[];if(this._sublayers){const e=this._sublayers.filter((e=>t.has(e.id))).toArray();i.push(...e.map((async e=>{const i=t.get(e.id);await i._switchSublayer(e),this._sublayerExtensions._register(i)})))}this.isInitialized&&i.push(this._initializeChildren()),await Promise.all(i)}_getProjectWebmapJSON(){if(!this.layer)return;let e=PortalLayerBase.fromEsriApiLayer(this.layer);if(!this.dynamicallyAddedLayer){const{id:t,title:i,layerType:r,visibility:s,opacity:a}=e;e={id:t,title:i,layerType:r,visibility:s,opacity:a}}return e}async _onDestroy(){this._watchHandles.forEach((e=>e?.remove())),await Promise.all(this.sublayerExtensions.toArray().map((e=>e.destroy()))),await super._onDestroy()}_getSerializableProperties(){return{...super._getSerializableProperties(),iconUrl:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.iconUrl:this.getDefault("iconUrl")},visibilityMode:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.visibilityMode:this.getDefault("visibilityMode"),default:"independent"},tpkSource:{serializeModes:["initial"]},layerListSettings:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.layerListSettings:this.getDefault("layerListSettings")},sublayerExtensions:{serializeModes:["initial","project"],serialize:e=>this.sublayerExtensions.map((e=>e.toItemUri())).toArray(),deserialize:e=>{_assignSublayerExtensions(this.sublayerExtensions,e,(e=>this._createSublayerExtension(e)))}},layer:{serializeModes:["initial","project"],serialize:e=>{if(this.layer){if((this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension)&&(this._layer.id||this._layer.title)){const e=PortalLayerBase.getLayerType(this._layer),t=this._getSerializableRefLayerProperties();return{$ref:this._originalRef||{id:this._layer.id,title:this._layer.title,subtype:this._getSerializableLayerType()},layerType:e,...t}}return PortalLayerBase.fromEsriApiLayer(this.layer)}return this._deferredLayerProperties?deepClone(this._deferredLayerProperties):void 0},isDefault:()=>{throw new Error("Missing implementation for _getSerializableProperties() > layer > default. Subclasses of LayerExtension must implement this.")},deserialize:e=>{if(isLayer(e)){if(e!==this.layer)throw new Error("Property 'layer' is read-only.")}else e&&(this._layer?this._applyLayerProperties(e,this.layer):this._deferredLayerProperties&&(this._deferredLayerProperties={...this._deferredLayerProperties,...e}))}},dynamicallyAddedLayer:{serializeModes:["project"],default:!1},requestHelper:{serialize:!1}}}_getSerializableLayerType(){}_getSerializableRefLayerProperties(){return{}}_createSublayerExtension(e){if(!this.supportsSublayers)throw new InvalidOperationError(ERR_ADD_SUBLAYERX_NOT_SUPPORTED);throw new Error("Missing implementation for _createSublayerExtension(). Subclasses of LayerExtension that support sublayers must implement this.")}async _onInitialize(){if(await super._onInitialize(),await this._createBackingLayer(),this._portalItem&&(await load(this._portalItem),await this._applyPortalItemProperties(this._portalItem),this.layer.title=this._portalItem.title,this.layer.portalItem=this._portalItem,this.iconUrl||(this.iconUrl=this._portalItem.thumbnailUrl),await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),this._resolveLayer(),!this.layer){const e=this._deferredLayerProperties.$ref;throw this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension?new InvalidOperationError(`No layer found matching reference "${"string"==typeof e?e:JSON.stringify(e)}".`):new InvalidOperationError("Cannot resolve layer reference: missing parent.")}this._deferredLayerProperties&&(await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),await this._initializeLayer(),await load(this.layer),this.supportsSublayers&&!this.layer.sublayers&&this.layer._set("sublayers",new Collection),this._sublayerExtensions.onParentInitialized()}async _postInitialize(){await super._postInitialize(),this.layerListSettings.onLayerExtensionInitialized(),this._watchHandles.push(onCollectionPropertyChange(this,"layer.sublayers",(async e=>{const t=(e.added??[]).map((e=>this.sublayerExtensions.forSublayer(e)));await Promise.all(t.map(this._onSublayerAddedPostInitialize))})))}_applyPortalItemProperties(e){throw new InvalidOperationError("Cannot use this type of layer extension with a PortalItem.")}async _initializeLayer(){}_createLayerListSettings(e){return new LayerExtensionLayerListSettings(e,this)}_createSublayerExtensionCollection(){return new SublayerExtensionCollectionImpl(this)}_capabilities(){return DEFAULT_CAPABILITIES}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.sublayerExtensions}async _createLayer(e){return PortalLayerBase.toEsriApiLayer(e)}_applyLayerProperties(e,t){checkArg("layerJson",e).isNotMissing();const i=e.layerType||e.type;return checkArg("layerJson.layerType",i).satisfies((e=>!e||e===this.getDefault("layer")?.layerType),ERR_LAYER_TYPE_MISMATCH),checkArg("layer",t).isNotMissing().satisfies((e=>this._isSupportedLayer(e)),ERR_LAYER_TYPE_MISMATCH),PortalLayerBase.applyToEsriApiLayer(e,t)}_setLayer(e){if(this._layer=e,e.watch("visible",this._onVisibleChanged),this.layer.watch("minScale",(()=>this.notifyChange("effectiveMinScale"))),this.layer.watch("maxScale",(()=>this.notifyChange("effectiveMaxScale"))),this.layer.watch("title",(()=>this.notifyChange("title"))),this.supportsSublayers)if(this._sublayers)this._setupSublayersHandles();else{const t=e.watch("sublayers",(()=>{this._setupSublayersHandles(),t.remove()}),!0)}this.notifyChange("layer"),this.notifyChange("title"),this.notifyChange("effectiveMinScale"),this.notifyChange("effectiveMaxScale"),this.notifyChange("isEffectivelyVisible")}_setupSublayersHandles(){this._sublayers.on("change",this._onSublayersChange),watchEach(this._sublayers,"visible",this._onSublayersSublayerVisibleChanged)}_ensureAChildSublayerVisible(e){for(const t of this._sublayers.toArray())t!==e&&(t.visible=!1)}_ensureAtMostOneChildSublayerVisible(){this.layer&&this._sublayers&&this._ensureAChildSublayerVisible(this._sublayers.find((e=>e.visible)))}}class SublayerExtensionCollectionImpl extends SublayerExtensionCollectionBase{constructor(e){super(e,"_sublayers"),this._layerExtension=e}add(e,t){if(checkArg("sublayerX",e).isNotMissing(),!this._layerExtension.supportsSublayers)throw new InvalidOperationError(ERR_ADD_SUBLAYERX_NOT_SUPPORTED);const i=e.sublayer?e.sublayer.layer:void 0;i&&i!==this._layerExtension.layer&&i.sublayers.remove(e.sublayer),super.add(e,t)}}class AllSublayerExtensionCollectionImpl extends ReadOnlyInitializableCollection{constructor(e){super(),this._layerExtension=e}get _collection(){return this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions))}findById(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.id===e))}findBySublayerId(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.sublayer.id===e))}forSublayer(e){return checkArg("sublayer",e).isNotMissing(),this.findBySublayerId(e.id)}emit(e,t){if("change"===e){const i=new Collection;i.addMany(t.added);const r=i.flatten((e=>e.sublayerExtensions)).toArray(),s=new Collection;s.addMany(t.removed);const a=s.flatten((e=>e.sublayerExtensions)).toArray(),n=new Collection;n.addMany(t.moved);const o=n.flatten((e=>e.sublayerExtensions)).toArray();return super.emit(e,{added:r,removed:a,moved:o,target:this})}return super.emit(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.sublayer}}let LayerExtensionLayerListSettings=class extends ExtensionBaseLayerListSettings{get _esriLayer(){return this._extension.layer}get _listModePath(){return"layer.listMode"}get _supportsChildren(){return this._extension.supportsSublayers}};LayerExtensionLayerListSettings=__decorate([serializable],LayerExtensionLayerListSettings);export{LayerExtensionLayerListSettings};let LayerExtensionSchema=class extends Schema{constructor(e){if(super(),this._layerBindings=new Map,this._layerExtension=e,this._bindSettingsToLayerProperties(),e.layer)this._onLayerResolved(e.layer);else{const t=e.watch("layer",(()=>{this._onLayerResolved(e.layer),t.remove()}),!0)}}_getPropertyBindings(){return{}}_getSetting(e,t){if(this._layerBindings.has(e)){let t=this._layerBindings.get(e);if("string"==typeof t&&(t={property:t}),t.hasOwnProperty("value"))return t.value;if(this._layerExtension.layer)return this._layerExtension.layer[t.property]}return super._getSetting(e,t)}_setSetting(e,t){if(this._layerBindings.has(e)){let i=this._layerBindings.get(e);if("string"==typeof i&&(i={property:i}),i.readonly||i.hasOwnProperty("value"))throw new InvalidOperationError(ERR_SCHEMA_READ_ONLY);if(this._layerExtension.layer)return void(this._layerExtension.layer[i.property]=t)}super._setSetting(e,t)}_bindSettingsToLayerProperties(){const e=this._getPropertyBindings();for(const t of Object.keys(e)){let i=e[t];"string"==typeof i&&(i={property:i}),this._layerBindings.set(t,i),i.hasOwnProperty("value")||this._layerExtension.watch(`layer.${i.property}`,(()=>this.notifyChange(t)),!i.hasOwnProperty("sync")||i.sync)}}_onLayerResolved(e){for(const t of this._layerBindings.keys())this.isModified(t)&&(e[t]=this[t],this.reset(t))}};LayerExtensionSchema=__decorate([serializable],LayerExtensionSchema);export{LayerExtensionSchema};export class ArrayWrappedCollection extends CollectionProxy{constructor(e,t){if(super(),this._layerExtension=e,this._property=t,this._layerProperty=e instanceof LayerExtension?"layer":"sublayer",e[this._layerProperty])this._onLayerResolved(e[this._layerProperty]);else{this._collection=new Collection;const t=e.watch(this._layerProperty,(()=>{const i=e[this._layerProperty];this.length&&(i[this._property]=this.toArray()),this._onLayerResolved(i),t.remove()}),!0)}}add(e,t){const i=this._layerExtension[this._layerProperty];i&&!i[this._property]&&(i[this._property]=[],this._collection=wrapArrayWithCollection(i[this._property])),super.add(e,t)}_onLayerResolved(e){this._collection=wrapArrayWithCollection(e[this._property]||[]),e.watch(this._property,(()=>{this._collection=wrapArrayWithCollection(e[this._property]||[])}),!0)}}export function _assignLayerExtensions(e,t){return compare(e,t,{onNew:(t,i)=>{e.add(t instanceof LayerExtension?t:LayerExtension.create(t),isLayerRef(t)?void 0:i)},onMatch:(t,i,r,s)=>{i instanceof LayerExtension||t.assignProperties(i),r===s||isLayerRef(i)||e.reorder(t,s)},onMissing:t=>{(hasMmapLayer([t])||isGroupLayerExtension(t)&&0===t.layerExtensions.toArray().length)&&e.remove(t)},equals:(e,t)=>t instanceof LayerExtension?t===e:!!LayerExtension._matchesRef(e.layer,t.layer)||e.id===t.id})}function wrapArrayWithCollection(e){const t=new Collection;return Object.defineProperty(t,"_items",{get:()=>e}),Object.defineProperty(t,"length",{get:()=>e.length,set:t=>e.length=t}),t}function getLayerXLogger(){return getLogger("geocortex.api.mapping.LayerExtension")}function isLayerRef(e){return e instanceof LayerExtension?!!e._deferredLayerProperties?.$ref:!isLayer(e.layer)&&!!e.layer?.$ref}
|
|
1
|
+
import{__decorate}from"tslib";import{ArgumentError}from"../ArgumentError.js";import{InvalidOperationError}from"../InvalidOperationError.js";import{ItemType}from"../ItemType.js";import{FeatureSourceBase}from"../data/FeatureSourceBase.js";import{Schema}from"../data/Schema.js";import{LayerBase as PortalLayerBase}from"../portal/LayerBase.js";import{ERR_LAYER_TYPE_MISMATCH}from"../portal/_layerHelper.js";import{DefaultArcGISRequestHelper}from"../support/ArcGISRequestHelper.js";import{ReadOnlyInitializableCollection}from"../support/ReadOnlyInitializableCollection.js";import{serializable}from"../support/Serializable.js";import{CollectionProxy}from"../utilities/CollectionProxy.js";import{isLayer}from"../utilities/_layers.js";import{checkArg}from"../utilities/checkArg.js";import{Collection,compare}from"../utilities/collection.js";import{load}from"../utilities/esri.js";import{isGroupLayerExtension}from"../utilities/extensions.js";import{hasMmapLayer}from"../utilities/layers.js";import{getLogger}from"../utilities/log.js";import{deepClone}from"../utilities/object.js";import{toPortalItem}from"../utilities/portal.js";import{onCollectionPropertyChange,watchEach}from"../utilities/watch.js";import{_assignSublayerExtensions}from"./_SublayerExtension.js";import{ExtensionBaseLayerListSettings,fromLayerListMode}from"./support/LayerListSettings.js";import{SublayerExtensionCollectionBase}from"./support/_SublayerExtensionCollection.js";const ERR_INVALID_LAYER_TYPE="Invalid type of layer for this type of layer extension.",ERR_FEATURES_NOT_SUPPORTED="This type of layer does not have features.",ERR_ADD_SUBLAYERX_NOT_SUPPORTED="This type of layer cannot have sublayers.",ERR_SCHEMA_READ_ONLY="This schema property is read-only.",DEFAULT_CAPABILITIES=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1});export class LayerExtension extends FeatureSourceBase{constructor(e){super(e),this._itemType=ItemType.LAYER_EXTENSION,this._watchHandles=[],this._dynamicallyAddedLayer=!1,this._visibilityMode="independent",this._onSublayerAddedPostInitialize=async e=>{try{await e.initialize()}catch(t){getLayerXLogger().error({message:`Error occurred while initializing sublayer extension for sublayer '${e.title??e.sublayer.id??e.id}'.`,error:t})}},this._onVisibleChanged=e=>{if("inherited"===this.visibilityMode&&this.supportsSublayers&&this._sublayers)for(const t of this._sublayers.toArray())t.visible=e;this.notifyChange("isEffectivelyVisible")},this._onSublayersSublayerVisibleChanged=(e,t,i,r)=>{e&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(r)},this._onSublayersChange=e=>{e.added?.length&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(e.added[e.added.length-1])};const t={...this.getDefaults(),...e};checkArg("properties.layer",t.layer).isNotMissing();const{layer:i}=t;let r;if(i?.hasOwnProperty("listMode")&&(r=fromLayerListMode(i.listMode)),this.layerListSettings=this._createLayerListSettings({...r,...t.layerListSettings}),isLayer(i))checkArg("properties.layer",i).satisfies((e=>this._isSupportedLayer(e)),ERR_INVALID_LAYER_TYPE),this._setLayer(i);else if(i){if(i.$portalItem){const e=i.$portalItem;this._portalItem=toPortalItem(e)}this._deferredLayerProperties=i}this._sublayerExtensions=this._createSublayerExtensionCollection(),this.allSublayerExtensions=new AllSublayerExtensionCollectionImpl(this),this.watch("parentLayerExtension.isEffectivelyVisible",(()=>this.notifyChange("isEffectivelyVisible"))),this.watch("layer.sublayers",(()=>this.notifyChange("_sublayers")))}get layer(){return this._layer}get mapExtension(){return this._mapExtension}get basemapExtension(){return this._basemapExtension}get groundExtension(){return this._groundExtension}get parentLayerExtension(){return this._parentLayerExtension}get hasFeatures(){return!1}get capabilities(){return this._capabilities()}get renderer(){}get visibilityMode(){return this._visibilityMode}set visibilityMode(e){this._visibilityMode=e,"exclusive"===e&&this._ensureAtMostOneChildSublayerVisible()}get sublayerExtensions(){return this._sublayerExtensions}get requestHelper(){return this._requestHelper||(this._requestHelper=new DefaultArcGISRequestHelper),this._requestHelper}set requestHelper(e){this._requestHelper=e}get title(){return this.layer?.title??this._deferredLayerProperties?.title??("string"==typeof this._deferredLayerProperties?.$ref?this._deferredLayerProperties?.$ref:this._deferredLayerProperties?.$ref?.title??this._deferredLayerProperties?.$ref?.id)??"Layer"}get supportsSublayers(){return!1}get effectiveMinScale(){return this.layer&&this.layer.minScale||0}get effectiveMaxScale(){return this.layer&&this.layer.maxScale||0}get isEffectivelyVisible(){const e=!!this.layer&&this.layer.visible;return this.parentLayerExtension?this.parentLayerExtension.isEffectivelyVisible&&e:e}get effectiveFullExtent(){return this.layer?this.layer.fullExtent:void 0}get canChangeScale(){return!0}get canChangeOpacity(){return!0}get canChangeLabels(){return!1}get _layerSupportsHideChildren(){return this.supportsSublayers}get _sublayers(){if(this.supportsSublayers)return this.layer?this.layer.sublayers:void 0}get dynamicallyAddedLayer(){return this._dynamicallyAddedLayer}set dynamicallyAddedLayer(e){this._dynamicallyAddedLayer=e}static create(e){if(!LayerExtension.factory)throw new InvalidOperationError("Cannot create layer extension: no layer extension factory has been registered.");return LayerExtension.factory.create(e)}static async fromPortalItem(e,t){checkArg("portalItemLike",e).isNotMissing();const i=t??{};checkArg("layerExtensionProperties.layer",i.layer).satisfies((e=>!isLayer(e)));const r={...i.layer};checkArg("layerExtensionProperties.layer.$ref",r.$ref).satisfies((e=>null==e));const s=new DefaultArcGISRequestHelper,a=toPortalItem(e);let n;await load(a);const o=a.typeKeywords??"";if("Map Service"===a.type)n=o.includes("Tiled")||o.includes("Hosted Service")?"ArcGISTiledMapServiceLayer":"ArcGISMapServiceLayer";else if("Feature Service"===a.type)n="ArcGISFeatureLayer";else if("Image Service"===a.type){const e=await LayerExtension._getLayerData(a.url,s);e.cacheType?"Map"===e.cacheType?n="ArcGISTiledImageServiceLayer":("Elevation"===e.cacheType||o.includes("Elevation 3D Layer"))&&(n="ArcGISTiledElevationServiceLayer"):n=e.singleFusedMapCache||e.tileInfo||o.includes("Hosted Service")?"ArcGISTiledImageServiceLayer":"ArcGISImageServiceLayer"}else if("CSV"===a.type)n="CSV";else if("KML"===a.type)n="KML";else if("Scene Service"===a.type)o.includes("3DObject")||o.includes("Point")?n="ArcGISSceneServiceLayer":o.includes("IntegratedMesh")?n="IntegratedMeshLayer":o.includes("PointCloud")?n="PointCloudLayer":o.includes("Building")&&(n="BuildingSceneLayer");else if("Stream Service"===a.type)n="ArcGISStreamLayer";else if("Vector Tile Service"===a.type)n="VectorTileLayer";else if("Feature Collection"===a.type){n="ArcGISFeatureLayer";const e=await a.fetchData();r.featureCollection=e}else if("WMTS"===a.type){n="WebTiledLayer";const e=await a.fetchData();Object.assign(r,e)}else if("WMS"===a.type){n="WMS";const e=await a.fetchData();Object.assign(r,e)}if(!n)throw new ArgumentError("portalItem","Could not determine correct type of LayerExtension to create from portal item");if(r.layerType&&r.layerType!==n)throw new ArgumentError("layerExtensionProperties.layer.layerType","Layer type defined in layer properties does not match layer type from portal item");return r.layerType=n,r.$portalItem=a,i.layer=r,LayerExtension.create(i)}static _matchesRef(e,t){if(!e||!t)return!1;const i=t.$ref;return"string"==typeof i?e.id===i||e.title===i:!!i&&(e.id===i.id||e.title===i.title&&!i.path)}static async _getLayerData(e,t){const i=await t.request(e,{query:{f:"json"}});if(!i||!i.data)throw new Error(`Response to request for url ${e} was invalid.`);return i.data}getFeatures(e,t){if(!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);return super.getFeatures(e,t)}getFullExtent(){return this.effectiveFullExtent}async addFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.addFeatures(e,t)}async updateFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.updateFeatures(e,t)}async deleteFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.deleteFeatures(e,t)}async _createBackingLayer(){this._portalItem||this.layer||this._deferredLayerProperties&&this._deferredLayerProperties.$ref?!this.layer&&this._portalItem&&this._setLayer(await this._createLayer(this.getDefaults().layer)):(this._setLayer(await this._createLayer(this._deferredLayerProperties)),checkArg("properties.layer",this._layer).satisfies((e=>this._isSupportedLayer(e)),ERR_INVALID_LAYER_TYPE),this._deferredLayerProperties=void 0)}_setMapExtension(e){const t=this.mapExtension;this._mapExtension=e,t&&this.featureSettings.formatSettings.parent===t.formatSettings&&(this.featureSettings.formatSettings.parent=void 0),e&&(this.featureSettings.formatSettings.parent||(this.featureSettings.formatSettings.parent=e.formatSettings)),this._resolveLayer(),this.notifyChange("mapExtension")}_setBasemapExtension(e){this._basemapExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),this.notifyChange("basemapExtension")}_setGroundExtension(e){this._groundExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),this.notifyChange("groundExtension")}_setParentLayerExtension(e){const t=this._parentLayerExtension;this._parentLayerExtension=e,t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=this.mapExtension?this.mapExtension.formatSettings:void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=void 0)),e&&((!this.featureSettings.formatSettings.parent||this.mapExtension&&this.featureSettings.formatSettings.parent===this.mapExtension.formatSettings)&&(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),this.taskSettings.parent||(this.taskSettings.parent=e.taskSettings)),this._resolveLayer(),this.notifyChange("parentLayerExtension")}_resolveLayer(e){if(this.layer||!this._deferredLayerProperties)return;const t=e=>LayerExtension._matchesRef(e,this._deferredLayerProperties);let i;e?i=e.find(t):this.basemapExtension?.basemap?(i=this.basemapExtension.basemap.baseLayers.find(t),i=i||this.basemapExtension.basemap.referenceLayers.find(t)):this.groundExtension?.ground?i=this.groundExtension.ground.layers.find(t):this.parentLayerExtension?.layer?i=this.parentLayerExtension.layer.layers.find(t):this.mapExtension&&(i=this.mapExtension.map.layers.find(t)),i&&this._isSupportedLayer(i)&&(this._setLayer(i),this._originalRef=this._deferredLayerProperties.$ref,this._deferredLayerProperties.$portalItem&&getLayerXLogger().warn("LayerExtension defined with both $ref and $portalItem. Ignoring $portalItem."))}async _switchLayer(e){if(e===this.layer)return;checkArg("newLayer",e).isNotMissing().satisfies((e=>this._isSupportedLayer(e)),ERR_INVALID_LAYER_TYPE),this.isInitialized&&await load(e);const t=new Map;if(this._sublayers)for(const e of this._sublayers.toArray())t.set(e.id,this.sublayerExtensions.forSublayer(e));e.visible=this.layer.visible,e.opacity=this.layer.opacity,e.listMode=this.layer.listMode,e.hasOwnProperty("labelsVisible")&&this.layer.hasOwnProperty("labelsVisible")&&(e.labelsVisible=this.layer.labelsVisible),this._setLayer(e);const i=[];if(this._sublayers){const e=this._sublayers.filter((e=>t.has(e.id))).toArray();i.push(...e.map((async e=>{const i=t.get(e.id);await i._switchSublayer(e),this._sublayerExtensions._register(i)})))}this.isInitialized&&i.push(this._initializeChildren()),await Promise.all(i)}_getProjectWebmapJSON(){if(!this.layer)return;let e=PortalLayerBase.fromEsriApiLayer(this.layer);if(!this.dynamicallyAddedLayer){const{id:t,title:i,layerType:r,visibility:s,opacity:a}=e;e={id:t,title:i,layerType:r,visibility:s,opacity:a}}return e}async _onDestroy(){this._watchHandles.forEach((e=>e?.remove())),await Promise.all(this.sublayerExtensions.toArray().map((e=>e.destroy()))),await super._onDestroy()}_getSerializableProperties(){return{...super._getSerializableProperties(),iconUrl:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.iconUrl:this.getDefault("iconUrl")},visibilityMode:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.visibilityMode:this.getDefault("visibilityMode"),default:"independent"},tpkSource:{serializeModes:["initial"]},layerListSettings:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.layerListSettings:this.getDefault("layerListSettings")},sublayerExtensions:{serializeModes:["initial","project"],serialize:e=>this.sublayerExtensions.map((e=>e.toItemUri())).toArray(),deserialize:e=>{_assignSublayerExtensions(this.sublayerExtensions,e,(e=>this._createSublayerExtension(e)))}},layer:{serializeModes:["initial","project"],serialize:e=>{if(this.layer){if((this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension)&&(this._layer.id||this._layer.title)){const e=PortalLayerBase.getLayerType(this._layer),t=this._getSerializableRefLayerProperties();return{$ref:this._originalRef||{id:this._layer.id,title:this._layer.title,subtype:this._getSerializableLayerType()},layerType:e,...t}}return PortalLayerBase.fromEsriApiLayer(this.layer)}return this._deferredLayerProperties?deepClone(this._deferredLayerProperties):void 0},isDefault:()=>{throw new Error("Missing implementation for _getSerializableProperties() > layer > default. Subclasses of LayerExtension must implement this.")},deserialize:e=>{if(isLayer(e)){if(e!==this.layer)throw new Error("Property 'layer' is read-only.")}else e&&(this._layer?this._applyLayerProperties(e,this.layer):this._deferredLayerProperties&&(this._deferredLayerProperties={...this._deferredLayerProperties,...e}))}},dynamicallyAddedLayer:{serializeModes:["project"],default:!1},requestHelper:{serialize:!1}}}_getSerializableLayerType(){}_getSerializableRefLayerProperties(){return{}}_createSublayerExtension(e){if(!this.supportsSublayers)throw new InvalidOperationError(ERR_ADD_SUBLAYERX_NOT_SUPPORTED);throw new Error("Missing implementation for _createSublayerExtension(). Subclasses of LayerExtension that support sublayers must implement this.")}async _onInitialize(){if(await super._onInitialize(),await this._createBackingLayer(),this._portalItem&&(await load(this._portalItem),await this._applyPortalItemProperties(this._portalItem),this.layer.title=this._portalItem.title,this.layer.portalItem=this._portalItem,this.iconUrl||(this.iconUrl=this._portalItem.thumbnailUrl),await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),this._resolveLayer(),!this.layer){const e=this._deferredLayerProperties.$ref;throw this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension?new InvalidOperationError(`No layer found matching reference "${"string"==typeof e?e:JSON.stringify(e)}".`):new InvalidOperationError("Cannot resolve layer reference: missing parent.")}this._deferredLayerProperties&&(await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),await this._initializeLayer(),await load(this.layer),this.supportsSublayers&&!this.layer.sublayers&&this.layer._set("sublayers",new Collection),this._sublayerExtensions.onParentInitialized()}async _postInitialize(){await super._postInitialize(),this.layerListSettings.onLayerExtensionInitialized(),this._watchHandles.push(onCollectionPropertyChange(this,"layer.sublayers",(async e=>{const t=(e.added??[]).map((e=>this.sublayerExtensions.forSublayer(e)));await Promise.all(t.map(this._onSublayerAddedPostInitialize))})))}_applyPortalItemProperties(e){throw new InvalidOperationError("Cannot use this type of layer extension with a PortalItem.")}async _initializeLayer(){}_createLayerListSettings(e){return new LayerExtensionLayerListSettings(e,this)}_createSublayerExtensionCollection(){return new SublayerExtensionCollectionImpl(this)}_capabilities(){return DEFAULT_CAPABILITIES}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.sublayerExtensions}async _createLayer(e){return PortalLayerBase.toEsriApiLayer(e)}_applyLayerProperties(e,t){checkArg("layerJson",e).isNotMissing();const i=e.layerType||e.type;return checkArg("layerJson.layerType",i).satisfies((e=>!e||e===this.getDefault("layer")?.layerType),ERR_LAYER_TYPE_MISMATCH),checkArg("layer",t).isNotMissing().satisfies((e=>this._isSupportedLayer(e)),ERR_LAYER_TYPE_MISMATCH),PortalLayerBase.applyToEsriApiLayer(e,t)}_setLayer(e){if(this._layer=e,e.watch("visible",this._onVisibleChanged),this.layer.watch("minScale",(()=>this.notifyChange("effectiveMinScale"))),this.layer.watch("maxScale",(()=>this.notifyChange("effectiveMaxScale"))),this.layer.watch("title",(()=>this.notifyChange("title"))),this.supportsSublayers)if(this._sublayers)this._setupSublayersHandles();else{const t=e.watch("sublayers",(()=>{this._setupSublayersHandles(),t.remove()}),!0)}this.notifyChange("layer"),this.notifyChange("title"),this.notifyChange("effectiveMinScale"),this.notifyChange("effectiveMaxScale"),this.notifyChange("isEffectivelyVisible")}_setupSublayersHandles(){this._sublayers.on("change",this._onSublayersChange),watchEach(this._sublayers,"visible",this._onSublayersSublayerVisibleChanged)}_ensureAChildSublayerVisible(e){for(const t of this._sublayers.toArray())t!==e&&(t.visible=!1)}_ensureAtMostOneChildSublayerVisible(){this.layer&&this._sublayers&&this._ensureAChildSublayerVisible(this._sublayers.find((e=>e.visible)))}}class SublayerExtensionCollectionImpl extends SublayerExtensionCollectionBase{constructor(e){super(e,"_sublayers"),this._layerExtension=e}add(e,t){if(checkArg("sublayerX",e).isNotMissing(),!this._layerExtension.supportsSublayers)throw new InvalidOperationError(ERR_ADD_SUBLAYERX_NOT_SUPPORTED);const i=e.sublayer?e.sublayer.layer:void 0;i&&i!==this._layerExtension.layer&&i.sublayers.remove(e.sublayer),super.add(e,t)}}class AllSublayerExtensionCollectionImpl extends ReadOnlyInitializableCollection{constructor(e){super(),this._layerExtension=e}get _collection(){return this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions))}findById(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.id===e))}findBySublayerId(e){return checkArg("id",e).isNotMissing(),this.find((t=>t.sublayer.id===e))}forSublayer(e){return checkArg("sublayer",e).isNotMissing(),this.findBySublayerId(e.id)}emit(e,t){if("change"===e){const i=new Collection;i.addMany(t.added);const r=i.flatten((e=>e.sublayerExtensions)).toArray(),s=new Collection;s.addMany(t.removed);const a=s.flatten((e=>e.sublayerExtensions)).toArray(),n=new Collection;n.addMany(t.moved);const o=n.flatten((e=>e.sublayerExtensions)).toArray();return super.emit(e,{added:r,removed:a,moved:o,target:this})}return super.emit(e,t)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.sublayer}}let LayerExtensionLayerListSettings=class extends ExtensionBaseLayerListSettings{get _esriLayer(){return this._extension.layer}get _listModePath(){return"layer.listMode"}get _supportsChildren(){return this._extension.supportsSublayers}};LayerExtensionLayerListSettings=__decorate([serializable],LayerExtensionLayerListSettings);export{LayerExtensionLayerListSettings};let LayerExtensionSchema=class extends Schema{constructor(e){if(super(),this._layerBindings=new Map,this._layerExtension=e,this._bindSettingsToLayerProperties(),e.layer)this._onLayerResolved(e.layer);else{const t=e.watch("layer",(()=>{this._onLayerResolved(e.layer),t.remove()}),!0)}}_getPropertyBindings(){return{}}_getSetting(e,t){if(this._layerBindings.has(e)){let t=this._layerBindings.get(e);if("string"==typeof t&&(t={property:t}),t.hasOwnProperty("value"))return t.value;if(this._layerExtension.layer)return this._layerExtension.layer[t.property]}return super._getSetting(e,t)}_setSetting(e,t){if(this._layerBindings.has(e)){let i=this._layerBindings.get(e);if("string"==typeof i&&(i={property:i}),i.readonly||i.hasOwnProperty("value"))throw new InvalidOperationError(ERR_SCHEMA_READ_ONLY);if(this._layerExtension.layer)return void(this._layerExtension.layer[i.property]=t)}super._setSetting(e,t)}_bindSettingsToLayerProperties(){const e=this._getPropertyBindings();for(const t of Object.keys(e)){let i=e[t];"string"==typeof i&&(i={property:i}),this._layerBindings.set(t,i),i.hasOwnProperty("value")||this._layerExtension.watch(`layer.${i.property}`,(()=>this.notifyChange(t)),!i.hasOwnProperty("sync")||i.sync)}}_onLayerResolved(e){for(const t of this._layerBindings.keys())this.isModified(t)&&(e[t]=this[t],this.reset(t))}};LayerExtensionSchema=__decorate([serializable],LayerExtensionSchema);export{LayerExtensionSchema};export class ArrayWrappedCollection extends CollectionProxy{constructor(e,t){if(super(),this._layerExtension=e,this._property=t,this._layerProperty=e instanceof LayerExtension?"layer":"sublayer",e[this._layerProperty])this._onLayerResolved(e[this._layerProperty]);else{this._collection=new Collection;const t=e.watch(this._layerProperty,(()=>{const i=e[this._layerProperty];this.length&&(i[this._property]=this.toArray()),this._onLayerResolved(i),t.remove()}),!0)}}add(e,t){const i=this._layerExtension[this._layerProperty];i&&!i[this._property]&&(i[this._property]=[],this._collection=wrapArrayWithCollection(i[this._property])),super.add(e,t)}_onLayerResolved(e){this._collection=wrapArrayWithCollection(e[this._property]||[]),e.watch(this._property,(()=>{this._collection=wrapArrayWithCollection(e[this._property]||[])}),!0)}}export function _assignLayerExtensions(e,t){return compare(e,t,{onNew:(t,i)=>{e.add(t instanceof LayerExtension?t:LayerExtension.create(t),isLayerRef(t)?void 0:i)},onMatch:(t,i,r,s)=>{i instanceof LayerExtension||t.assignProperties(i),r===s||isLayerRef(i)||e.reorder(t,s)},onMissing:t=>{(hasMmapLayer([t])||isGroupLayerExtension(t)&&0===t.layerExtensions.toArray().length)&&e.remove(t)},equals:(e,t)=>t instanceof LayerExtension?t===e:!!LayerExtension._matchesRef(e.layer,t.layer)||e.id===t.id})}function wrapArrayWithCollection(e){const t=new Collection;return Object.defineProperty(t,"_items",{get:()=>e}),Object.defineProperty(t,"length",{get:()=>e.length,set:t=>e.length=t}),t}function getLayerXLogger(){return getLogger("geocortex.api.mapping.LayerExtension")}function isLayerRef(e){return e instanceof LayerExtension?!!e._deferredLayerProperties?.$ref:!isLayer(e.layer)&&!!e.layer?.$ref}
|
|
@@ -203,6 +203,11 @@ export declare abstract class SublayerExtension<TProperties extends SublayerExte
|
|
|
203
203
|
* its renderer.
|
|
204
204
|
*/
|
|
205
205
|
get canChangeRenderer(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Determines whether the type of sublayer being extended supports changing
|
|
208
|
+
* labels. Default is false.
|
|
209
|
+
*/
|
|
210
|
+
get canChangeLabels(): boolean;
|
|
206
211
|
/**
|
|
207
212
|
* The sublayer's sublayers.
|
|
208
213
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{InvalidOperationError}from"../InvalidOperationError.js";import{isSublayerExtension,ItemType}from"../ItemType.js";import{FeatureSourceBase}from"../data/FeatureSourceBase.js";import{Schema}from"../data/Schema.js";import{serializable}from"../support/Serializable.js";import{isBuildingComponentSublayer,isBuildingGroupSublayer,isKMLSublayer,isMapImageSublayer,isTileLayer,isWMSSublayer,isWMTSSublayer}from"../utilities/_layers.js";import{checkArg}from"../utilities/checkArg.js";import{compare}from"../utilities/collection.js";import{load}from"../utilities/esri.js";import{getLogger}from"../utilities/log.js";import{parse}from"../utilities/number.js";import{deepClone}from"../utilities/object.js";import{onCollectionPropertyChange,watchCollectionPropertyEach}from"../utilities/watch.js";import{fromLayerListMode,LayerListSettings}from"./support/LayerListSettings.js";import{SublayerExtensionCollectionBase}from"./support/_SublayerExtensionCollection.js";const log=getLogger("SublayerExtension"),ERR_INVALID_SUBLAYER_TYPE="Invalid type of sublayer for this type of sublayer extension.",ERR_FEATURES_NOT_SUPPORTED="This type of layer does not have features.",ERR_SUBLAYERX_NOT_SUPPORTED="This type of sublayer extension cannot have child sublayer extensions.",DEFAULT_CAPABILITIES=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1});export function getSublayerType(e){if(isMapImageSublayer(e))return isTileLayer(e?.layer)?"ArcGISTiledSublayer":"ArcGISMapServiceSublayer";if(isKMLSublayer(e))return"KMLSublayer";if(isWMTSSublayer(e))return"WMTSSublayer";if(isWMSSublayer(e))return"WMSSublayer";if(isBuildingComponentSublayer(e))return"BuildingComponentSublayer";if(isBuildingGroupSublayer(e))return"BuildingGroupSublayer";throw new Error(`Unknown sublayer type for ESRI sublayer: ${e}`)}export class SublayerExtension extends FeatureSourceBase{constructor(e){super(e),this._itemType=ItemType.SUBLAYER_EXTENSION,this._watchHandles=[],this._onSublayerAddedPostInitialize=async e=>{try{await e.initialize()}catch(t){log.error({message:`Error occurred while initializing sublayer extension for sublayer '${e.title??e.sublayer.id??e.id}'.`,error:t})}},this._onSetSublayerVisible=e=>{if("inherited"===this.visibilityMode&&this.supportsSublayers&&this.sublayerExtensions)for(const t of this.sublayerExtensions.toArray())t.sublayer&&t.canToggleVisibility&&(t.sublayer.visible=e);this.notifyChange("isEffectivelyVisible")},this._onSetSublayersSublayerVisible=(e,t,i,s)=>{e&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(s)},this._onSublayersChange=e=>{e.added?.length&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(e.added[e.added.length-1])};const t=e||{};this._visibilityMode=this.canToggleVisibility?"independent":"inherited",this._sublayerExtensions=this._createSublayerExtensionCollection();const i=t.sublayer;let s;i?.hasOwnProperty("listMode")&&(s=fromLayerListMode(i.listMode)),this.layerListSettings=this._createLayerListSettings({...s,...t.layerListSettings}),isSublayer(i)?(checkArg("properties.sublayer",i).satisfies((e=>this._isSupportedSublayer(e)),ERR_INVALID_SUBLAYER_TYPE),this._setSublayer(i)):i&&(this._deferredSublayerProperties=i),this.watch("parentSublayerExtension.isEffectivelyVisible",(()=>this.notifyChange("isEffectivelyVisible")))}get sublayer(){return this._sublayer}get layerExtension(){return this._layerExtension}get parentSublayerExtension(){return this._parentSublayerExtension}get hasFeatures(){return!1}get sublayerExtensions(){return this._sublayerExtensions}get renderer(){}get visibilityMode(){return this.canToggleVisibility?this._visibilityMode:"inherited"}set visibilityMode(e){checkArg("visibilityMode",e).satisfies((e=>this.canToggleVisibility||"inherited"===e),'Sublayers of this type only support a visibility mode of "inherited".'),this._visibilityMode=e,"exclusive"===e&&this._ensureAtMostOneChildSublayerVisible()}get capabilities(){return this._capabilities()}get effectiveMinScale(){const e=this.sublayer?this.sublayer.minScale:0;if(this.parentSublayerExtension){const t=this.parentSublayerExtension.effectiveMinScale||1/0;if(t<(e||1/0))return t}if(this.layerExtension){const t=this.layerExtension.effectiveMinScale||1/0;if(t<(e||1/0))return t}return e}get effectiveMaxScale(){const e=this.sublayer?this.sublayer.maxScale:0;return this.parentSublayerExtension&&this.parentSublayerExtension.effectiveMaxScale>e?this.parentSublayerExtension.effectiveMaxScale:this.layerExtension&&this.layerExtension.effectiveMaxScale>e?this.layerExtension.effectiveMaxScale:e}get isEffectivelyVisible(){const e=!!this.sublayer&&this.sublayer.visible;return this.parentSublayerExtension?this.parentSublayerExtension.isEffectivelyVisible&&e:this.layerExtension?this.layerExtension.isEffectivelyVisible&&e:e}get title(){return this.sublayer?.title??("string"==typeof this._deferredSublayerProperties?.$ref||"number"==typeof this._deferredSublayerProperties?.$ref?this._deferredSublayerProperties?.$ref.toString():this._deferredSublayerProperties?.$ref?.title??this._deferredSublayerProperties?.$ref?.id.toString())??"Sublayer"}get supportsSublayers(){return!1}get canToggleVisibility(){return!0}get canChangeOpacity(){return!0}get canChangeScale(){return!0}get canChangeRenderer(){return!1}get _layerSupportsHideChildren(){return!1}get _sublayers(){if(this.supportsSublayers)return this.sublayer?.sublayers}get effectiveFullExtent(){return this._effectiveFullExtent?this._effectiveFullExtent:this.parentSublayerExtension?this.parentSublayerExtension.effectiveFullExtent:this.layerExtension?this.layerExtension.effectiveFullExtent:void 0}static create(e){if(!SublayerExtension.factory)throw new InvalidOperationError("Cannot create sublayer extension: no sublayer extension factory has been registered.");return SublayerExtension.factory.create(e)}static _matchesRef(e,t,i){if(!e||!t)return!1;let s=t.$ref;if("string"==typeof s){const e=parse(s);s={id:isNaN(e)?s:e,title:s}}else"number"==typeof s&&(s={id:s});return"both"===i?e.id===s.id&&e.title===s.title:"by-id"===i?e.id===s.id:"by-title"===i&&e.title===s.title}getFeatures(e,t){if(!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);return super.getFeatures(e,t)}getFullExtent(){return this.effectiveFullExtent}async addFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.addFeatures(e,t)}async updateFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.updateFeatures(e,t)}async deleteFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.deleteFeatures(e,t)}_resolveSublayer(){if(this._sublayer||!this._deferredSublayerProperties||!this.layerExtension||!this.layerExtension.layer||!this.layerExtension.layer.sublayers)return;const e=e=>t=>SublayerExtension._matchesRef(t,this._deferredSublayerProperties,e),t=this.layerExtension.layer.sublayers.flatten((e=>e.sublayers));let i=t.find(e("both"));if(i||(i=t.find(e("by-title"))),i||(i=t.find(e("by-id"))),i&&this._isSupportedSublayer(i)){this._setSublayer(i);const e={sublayer:this._deferredSublayerProperties};this.assignProperties(e),this._originalRef=this._deferredSublayerProperties.$ref,this._deferredSublayerProperties=void 0}}_setLayerExtension(e){const t=this.layerExtension;this._layerExtension=e,this.layerExtension&&(this.layerExtension.watch("effectiveMinScale",(()=>this.notifyChange("effectiveMinScale"))),this.layerExtension.watch("effectiveMaxScale",(()=>this.notifyChange("effectiveMaxScale"))),this.layerExtension.watch("isEffectivelyVisible",(()=>this.notifyChange("isEffectivelyVisible")))),this._parentSublayerExtension||(t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=void 0)),e&&(this.featureSettings.formatSettings.parent||(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),this.taskSettings.parent||(this.taskSettings.parent=e.taskSettings))),this._resolveSublayer(),this.notifyChange("layerExtension"),this._sublayerExtensions.onLayerExtensionChanged()}_setParentSublayerExtension(e){const t=this._parentSublayerExtension;this._parentSublayerExtension=e,this.parentSublayerExtension&&(this.parentSublayerExtension.watch("effectiveMinScale",(()=>this.notifyChange("effectiveMinScale"))),this.parentSublayerExtension.watch("effectiveMaxScale",(()=>this.notifyChange("effectiveMaxScale")))),t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=this.layerExtension?this.layerExtension.featureSettings.formatSettings:void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=this.layerExtension?this.layerExtension.taskSettings:void 0)),e&&((!this.featureSettings.formatSettings.parent||this.layerExtension&&this.featureSettings.formatSettings.parent===this.layerExtension.featureSettings.formatSettings)&&(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),(!this.taskSettings.parent||this.layerExtension&&this.taskSettings.parent===this.layerExtension.taskSettings)&&(this.taskSettings.parent=e.taskSettings)),this._resolveSublayer(),this.notifyChange("parentSublayerExtension")}async _switchSublayer(e){if(e===this.sublayer)return;checkArg("newSublayer",e).isNotMissing().satisfies((e=>e.id===this.sublayer.id),"Sublayer ID must match existing sublayer.").satisfies((e=>this._isSupportedSublayer(e)),ERR_INVALID_SUBLAYER_TYPE),this.isInitialized&&await load(e);const t=new Map;if(this.sublayer?.sublayers)for(const e of this.sublayer.sublayers.toArray())t.set(e.id,this.sublayerExtensions.forSublayer(e));this.canToggleVisibility&&(e.visible=this.sublayer.visible),this.canChangeOpacity&&(e.opacity=this.sublayer.opacity),this._setSublayer(e);const i=[];if(this.sublayer.sublayers){const e=this.sublayer.sublayers.filter((e=>t.has(e.id))).toArray();i.push(...e.map((async e=>{const i=t.get(e.id);await i._switchSublayer(e),this._sublayerExtensions._register(i)})))}this.isInitialized&&i.push(this._initializeChildren()),await Promise.all(i)}async _postInitialize(){await super._postInitialize(),this._watchHandles.push(onCollectionPropertyChange(this,"sublayer.sublayers",(async e=>{const t=(e.added??[]).map((e=>this.sublayerExtensions.forSublayer(e)));await Promise.all(t.map(this._onSublayerAddedPostInitialize))})))}async _onDestroy(){this._watchHandles.forEach((e=>e?.remove())),await Promise.all(this.sublayerExtensions.toArray().map((e=>e.destroy()))),await super._onDestroy()}_getSerializableProperties(){return{...super._getSerializableProperties(),iconUrl:"initial",visibilityMode:{serializeModes:["initial"],default:this.canToggleVisibility?"independent":"inherited"},layerListSettings:"initial",sublayerExtensions:{serializeModes:["initial","project"],serialize:()=>this.sublayerExtensions.map((e=>e.toItemUri())).toArray(),deserialize:e=>{_assignSublayerExtensions(this.sublayerExtensions,e,(e=>this._createSublayerExtension(e)))}},sublayer:{serializeModes:["initial","project"],serialize:()=>{if(this.sublayer){if(!this._layerExtension)return this._serializeSublayer(this._sublayer);{const e=getSublayerType(this._sublayer);if(this._originalRef)return{$ref:this._originalRef,$sublayerType:e};if(this._sublayer.title||this._sublayer.id)return{...this._createSublayerRef(),$sublayerType:e}}}else if(this._deferredSublayerProperties)return deepClone(this._deferredSublayerProperties)},deserialize:e=>{if(isSublayer(e)){if(e!==this.sublayer)throw new Error("Property 'sublayer' is read-only.")}else this._sublayer?this._applySublayerProperties(e,this._sublayer):this._deferredSublayerProperties&&(this._deferredSublayerProperties={...this._deferredSublayerProperties,...e})}},requestHelper:{serialize:!1}}}_createSublayerExtension(e){throw new InvalidOperationError(ERR_SUBLAYERX_NOT_SUPPORTED)}_createSchema(){return new SublayerSchema(this)}_createLayerListSettings(e){return new LayerListSettings(e)}_capabilities(){return DEFAULT_CAPABILITIES}async _onInitialize(){if(await super._onInitialize(),this._sublayer||this._deferredSublayerProperties&&this._deferredSublayerProperties?.$ref||(this._setSublayer(await this._createSublayer(this._deferredSublayerProperties)),this._deferredSublayerProperties=void 0),this._resolveSublayer(),!this._sublayer){const e=this._deferredSublayerProperties?.$ref;if(!this._layerExtension)throw new InvalidOperationError("Cannot resolve sublayer reference: missing parent layer extension.");throw new InvalidOperationError(`No sublayer found matching reference "${e}".`)}this._sublayerExtensions.onParentInitialized()}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.sublayerExtensions}_createSublayerRef(){return{$ref:{id:this._sublayer.id,title:this._sublayer.title}}}_createSublayerExtensionCollection(){return new SubSublayerExtensionCollection(this)}_watchSublayerProperties(){this._watchHandles.push(this.sublayer.watch("minScale",(()=>this._notifyChange("effectiveMinScale")),!0),this.sublayer.watch("maxScale",(()=>this._notifyChange("effectiveMaxScale")),!0))}_setSublayer(e){this._sublayer=e,this._watchHandles.push(e.watch("visible",this._onSetSublayerVisible,!0)),this.supportsSublayers&&this._watchHandles.push(onCollectionPropertyChange(e,"sublayers",this._onSublayersChange,!0),watchCollectionPropertyEach(e,"sublayers","visible",this._onSetSublayersSublayerVisible,!0)),this._onSetSublayerVisible(this.sublayer.visible),"exclusive"===this.visibilityMode&&this._ensureAtMostOneChildSublayerVisible(),this._watchSublayerProperties(),this.notifyChange("sublayer"),this.notifyChange("title"),this.notifyChange("effectiveMinScale"),this.notifyChange("effectiveMaxScale"),this.notifyChange("isEffectivelyVisible")}_ensureAChildSublayerVisible(e){for(const t of this._sublayers.toArray())t!==e&&(t.visible=!1)}_ensureAtMostOneChildSublayerVisible(){this.sublayer&&this._sublayers&&this._ensureAChildSublayerVisible(this._sublayers.find((e=>e.visible)))}}let SublayerSchema=class extends Schema{constructor(e){super(),this._sublayerExtension=e}get spatialReference(){if(this._sublayerExtension.layerExtension)return this._sublayerExtension.layerExtension.schema.spatialReference}set spatialReference(e){throw new InvalidOperationError("Cannot set sublayer schema spatial reference.")}};SublayerSchema=__decorate([serializable],SublayerSchema);export{SublayerSchema};export class SubSublayerExtensionCollection extends SublayerExtensionCollectionBase{constructor(e){super(e,"sublayer.sublayers")}get _layerExtension(){return this._parent.layerExtension}add(e,t){if(checkArg("sublayerX",e).isNotMissing(),!this._parent.supportsSublayers)throw new InvalidOperationError(ERR_SUBLAYERX_NOT_SUPPORTED);e.sublayer&&this._parent.sublayer&&!this._parent.sublayer.sublayers&&(this._parent.sublayer.sublayers=[]),e.parentSublayerExtension&&e.parentSublayerExtension.sublayerExtensions.remove(e),super.add(e,t)}_onAdded(e){super._onAdded(e),e._setParentSublayerExtension(this._parent)}_onRemoved(e){super._onRemoved(e),e._setParentSublayerExtension(void 0)}}export function _assignSublayerExtensions(e,t,i){compare(e,t,{onNew:(t,s)=>{e.add(isSublayerExtension(t)?t:i(t),isSublayerRef(t)?void 0:s)},onMatch:(t,i,s,r)=>{isSublayerExtension(i)||t.assignProperties(i),s===r||isSublayerRef(i)||e.reorder(t,r)},equals:(e,t)=>isSublayerExtension(t)?t===e:!!SublayerExtension._matchesRef(e.sublayer,t.sublayer,"both")||e.id===t.id})}function isSublayer(e){return e&&"function"==typeof e.get}function isSublayerRef(e){return isSublayerExtension(e)?!!e._deferredSublayerProperties?.$ref:!isSublayer(e.sublayer)&&!!e.sublayer?.$ref}
|
|
1
|
+
import{__decorate}from"tslib";import{InvalidOperationError}from"../InvalidOperationError.js";import{isSublayerExtension,ItemType}from"../ItemType.js";import{FeatureSourceBase}from"../data/FeatureSourceBase.js";import{Schema}from"../data/Schema.js";import{serializable}from"../support/Serializable.js";import{isBuildingComponentSublayer,isBuildingGroupSublayer,isKMLSublayer,isMapImageSublayer,isTileLayer,isWMSSublayer,isWMTSSublayer}from"../utilities/_layers.js";import{checkArg}from"../utilities/checkArg.js";import{compare}from"../utilities/collection.js";import{load}from"../utilities/esri.js";import{getLogger}from"../utilities/log.js";import{parse}from"../utilities/number.js";import{deepClone}from"../utilities/object.js";import{onCollectionPropertyChange,watchCollectionPropertyEach}from"../utilities/watch.js";import{fromLayerListMode,LayerListSettings}from"./support/LayerListSettings.js";import{SublayerExtensionCollectionBase}from"./support/_SublayerExtensionCollection.js";const log=getLogger("SublayerExtension"),ERR_INVALID_SUBLAYER_TYPE="Invalid type of sublayer for this type of sublayer extension.",ERR_FEATURES_NOT_SUPPORTED="This type of layer does not have features.",ERR_SUBLAYERX_NOT_SUPPORTED="This type of sublayer extension cannot have child sublayer extensions.",DEFAULT_CAPABILITIES=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1});export function getSublayerType(e){if(isMapImageSublayer(e))return isTileLayer(e?.layer)?"ArcGISTiledSublayer":"ArcGISMapServiceSublayer";if(isKMLSublayer(e))return"KMLSublayer";if(isWMTSSublayer(e))return"WMTSSublayer";if(isWMSSublayer(e))return"WMSSublayer";if(isBuildingComponentSublayer(e))return"BuildingComponentSublayer";if(isBuildingGroupSublayer(e))return"BuildingGroupSublayer";throw new Error(`Unknown sublayer type for ESRI sublayer: ${e}`)}export class SublayerExtension extends FeatureSourceBase{constructor(e){super(e),this._itemType=ItemType.SUBLAYER_EXTENSION,this._watchHandles=[],this._onSublayerAddedPostInitialize=async e=>{try{await e.initialize()}catch(t){log.error({message:`Error occurred while initializing sublayer extension for sublayer '${e.title??e.sublayer.id??e.id}'.`,error:t})}},this._onSetSublayerVisible=e=>{if("inherited"===this.visibilityMode&&this.supportsSublayers&&this.sublayerExtensions)for(const t of this.sublayerExtensions.toArray())t.sublayer&&t.canToggleVisibility&&(t.sublayer.visible=e);this.notifyChange("isEffectivelyVisible")},this._onSetSublayersSublayerVisible=(e,t,i,s)=>{e&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(s)},this._onSublayersChange=e=>{e.added?.length&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(e.added[e.added.length-1])};const t=e||{};this._visibilityMode=this.canToggleVisibility?"independent":"inherited",this._sublayerExtensions=this._createSublayerExtensionCollection();const i=t.sublayer;let s;i?.hasOwnProperty("listMode")&&(s=fromLayerListMode(i.listMode)),this.layerListSettings=this._createLayerListSettings({...s,...t.layerListSettings}),isSublayer(i)?(checkArg("properties.sublayer",i).satisfies((e=>this._isSupportedSublayer(e)),ERR_INVALID_SUBLAYER_TYPE),this._setSublayer(i)):i&&(this._deferredSublayerProperties=i),this.watch("parentSublayerExtension.isEffectivelyVisible",(()=>this.notifyChange("isEffectivelyVisible")))}get sublayer(){return this._sublayer}get layerExtension(){return this._layerExtension}get parentSublayerExtension(){return this._parentSublayerExtension}get hasFeatures(){return!1}get sublayerExtensions(){return this._sublayerExtensions}get renderer(){}get visibilityMode(){return this.canToggleVisibility?this._visibilityMode:"inherited"}set visibilityMode(e){checkArg("visibilityMode",e).satisfies((e=>this.canToggleVisibility||"inherited"===e),'Sublayers of this type only support a visibility mode of "inherited".'),this._visibilityMode=e,"exclusive"===e&&this._ensureAtMostOneChildSublayerVisible()}get capabilities(){return this._capabilities()}get effectiveMinScale(){const e=this.sublayer?this.sublayer.minScale:0;if(this.parentSublayerExtension){const t=this.parentSublayerExtension.effectiveMinScale||1/0;if(t<(e||1/0))return t}if(this.layerExtension){const t=this.layerExtension.effectiveMinScale||1/0;if(t<(e||1/0))return t}return e}get effectiveMaxScale(){const e=this.sublayer?this.sublayer.maxScale:0;return this.parentSublayerExtension&&this.parentSublayerExtension.effectiveMaxScale>e?this.parentSublayerExtension.effectiveMaxScale:this.layerExtension&&this.layerExtension.effectiveMaxScale>e?this.layerExtension.effectiveMaxScale:e}get isEffectivelyVisible(){const e=!!this.sublayer&&this.sublayer.visible;return this.parentSublayerExtension?this.parentSublayerExtension.isEffectivelyVisible&&e:this.layerExtension?this.layerExtension.isEffectivelyVisible&&e:e}get title(){return this.sublayer?.title??("string"==typeof this._deferredSublayerProperties?.$ref||"number"==typeof this._deferredSublayerProperties?.$ref?this._deferredSublayerProperties?.$ref.toString():this._deferredSublayerProperties?.$ref?.title??this._deferredSublayerProperties?.$ref?.id.toString())??"Sublayer"}get supportsSublayers(){return!1}get canToggleVisibility(){return!0}get canChangeOpacity(){return!0}get canChangeScale(){return!0}get canChangeRenderer(){return!1}get canChangeLabels(){return!1}get _layerSupportsHideChildren(){return!1}get _sublayers(){if(this.supportsSublayers)return this.sublayer?.sublayers}get effectiveFullExtent(){return this._effectiveFullExtent?this._effectiveFullExtent:this.parentSublayerExtension?this.parentSublayerExtension.effectiveFullExtent:this.layerExtension?this.layerExtension.effectiveFullExtent:void 0}static create(e){if(!SublayerExtension.factory)throw new InvalidOperationError("Cannot create sublayer extension: no sublayer extension factory has been registered.");return SublayerExtension.factory.create(e)}static _matchesRef(e,t,i){if(!e||!t)return!1;let s=t.$ref;if("string"==typeof s){const e=parse(s);s={id:isNaN(e)?s:e,title:s}}else"number"==typeof s&&(s={id:s});return"both"===i?e.id===s.id&&e.title===s.title:"by-id"===i?e.id===s.id:"by-title"===i&&e.title===s.title}getFeatures(e,t){if(!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);return super.getFeatures(e,t)}getFullExtent(){return this.effectiveFullExtent}async addFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.addFeatures(e,t)}async updateFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.updateFeatures(e,t)}async deleteFeatures(e,t){if(checkArg("features",e).isNotMissing(),!this.hasFeatures)throw new InvalidOperationError(ERR_FEATURES_NOT_SUPPORTED);await super.deleteFeatures(e,t)}_resolveSublayer(){if(this._sublayer||!this._deferredSublayerProperties||!this.layerExtension||!this.layerExtension.layer||!this.layerExtension.layer.sublayers)return;const e=e=>t=>SublayerExtension._matchesRef(t,this._deferredSublayerProperties,e),t=this.layerExtension.layer.sublayers.flatten((e=>e.sublayers));let i=t.find(e("both"));if(i||(i=t.find(e("by-title"))),i||(i=t.find(e("by-id"))),i&&this._isSupportedSublayer(i)){this._setSublayer(i);const e={sublayer:this._deferredSublayerProperties};this.assignProperties(e),this._originalRef=this._deferredSublayerProperties.$ref,this._deferredSublayerProperties=void 0}}_setLayerExtension(e){const t=this.layerExtension;this._layerExtension=e,this.layerExtension&&(this.layerExtension.watch("effectiveMinScale",(()=>this.notifyChange("effectiveMinScale"))),this.layerExtension.watch("effectiveMaxScale",(()=>this.notifyChange("effectiveMaxScale"))),this.layerExtension.watch("isEffectivelyVisible",(()=>this.notifyChange("isEffectivelyVisible")))),this._parentSublayerExtension||(t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=void 0)),e&&(this.featureSettings.formatSettings.parent||(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),this.taskSettings.parent||(this.taskSettings.parent=e.taskSettings))),this._resolveSublayer(),this.notifyChange("layerExtension"),this._sublayerExtensions.onLayerExtensionChanged()}_setParentSublayerExtension(e){const t=this._parentSublayerExtension;this._parentSublayerExtension=e,this.parentSublayerExtension&&(this.parentSublayerExtension.watch("effectiveMinScale",(()=>this.notifyChange("effectiveMinScale"))),this.parentSublayerExtension.watch("effectiveMaxScale",(()=>this.notifyChange("effectiveMaxScale")))),t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=this.layerExtension?this.layerExtension.featureSettings.formatSettings:void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=this.layerExtension?this.layerExtension.taskSettings:void 0)),e&&((!this.featureSettings.formatSettings.parent||this.layerExtension&&this.featureSettings.formatSettings.parent===this.layerExtension.featureSettings.formatSettings)&&(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),(!this.taskSettings.parent||this.layerExtension&&this.taskSettings.parent===this.layerExtension.taskSettings)&&(this.taskSettings.parent=e.taskSettings)),this._resolveSublayer(),this.notifyChange("parentSublayerExtension")}async _switchSublayer(e){if(e===this.sublayer)return;checkArg("newSublayer",e).isNotMissing().satisfies((e=>e.id===this.sublayer.id),"Sublayer ID must match existing sublayer.").satisfies((e=>this._isSupportedSublayer(e)),ERR_INVALID_SUBLAYER_TYPE),this.isInitialized&&await load(e);const t=new Map;if(this.sublayer?.sublayers)for(const e of this.sublayer.sublayers.toArray())t.set(e.id,this.sublayerExtensions.forSublayer(e));this.canToggleVisibility&&(e.visible=this.sublayer.visible),this.canChangeOpacity&&(e.opacity=this.sublayer.opacity),this._setSublayer(e);const i=[];if(this.sublayer.sublayers){const e=this.sublayer.sublayers.filter((e=>t.has(e.id))).toArray();i.push(...e.map((async e=>{const i=t.get(e.id);await i._switchSublayer(e),this._sublayerExtensions._register(i)})))}this.isInitialized&&i.push(this._initializeChildren()),await Promise.all(i)}async _postInitialize(){await super._postInitialize(),this._watchHandles.push(onCollectionPropertyChange(this,"sublayer.sublayers",(async e=>{const t=(e.added??[]).map((e=>this.sublayerExtensions.forSublayer(e)));await Promise.all(t.map(this._onSublayerAddedPostInitialize))})))}async _onDestroy(){this._watchHandles.forEach((e=>e?.remove())),await Promise.all(this.sublayerExtensions.toArray().map((e=>e.destroy()))),await super._onDestroy()}_getSerializableProperties(){return{...super._getSerializableProperties(),iconUrl:"initial",visibilityMode:{serializeModes:["initial"],default:this.canToggleVisibility?"independent":"inherited"},layerListSettings:"initial",sublayerExtensions:{serializeModes:["initial","project"],serialize:()=>this.sublayerExtensions.map((e=>e.toItemUri())).toArray(),deserialize:e=>{_assignSublayerExtensions(this.sublayerExtensions,e,(e=>this._createSublayerExtension(e)))}},sublayer:{serializeModes:["initial","project"],serialize:()=>{if(this.sublayer){if(!this._layerExtension)return this._serializeSublayer(this._sublayer);{const e=getSublayerType(this._sublayer);if(this._originalRef)return{$ref:this._originalRef,$sublayerType:e};if(this._sublayer.title||this._sublayer.id)return{...this._createSublayerRef(),$sublayerType:e}}}else if(this._deferredSublayerProperties)return deepClone(this._deferredSublayerProperties)},deserialize:e=>{if(isSublayer(e)){if(e!==this.sublayer)throw new Error("Property 'sublayer' is read-only.")}else this._sublayer?this._applySublayerProperties(e,this._sublayer):this._deferredSublayerProperties&&(this._deferredSublayerProperties={...this._deferredSublayerProperties,...e})}},requestHelper:{serialize:!1}}}_createSublayerExtension(e){throw new InvalidOperationError(ERR_SUBLAYERX_NOT_SUPPORTED)}_createSchema(){return new SublayerSchema(this)}_createLayerListSettings(e){return new LayerListSettings(e)}_capabilities(){return DEFAULT_CAPABILITIES}async _onInitialize(){if(await super._onInitialize(),this._sublayer||this._deferredSublayerProperties&&this._deferredSublayerProperties?.$ref||(this._setSublayer(await this._createSublayer(this._deferredSublayerProperties)),this._deferredSublayerProperties=void 0),this._resolveSublayer(),!this._sublayer){const e=this._deferredSublayerProperties?.$ref;if(!this._layerExtension)throw new InvalidOperationError("Cannot resolve sublayer reference: missing parent layer extension.");throw new InvalidOperationError(`No sublayer found matching reference "${e}".`)}this._sublayerExtensions.onParentInitialized()}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.sublayerExtensions}_createSublayerRef(){return{$ref:{id:this._sublayer.id,title:this._sublayer.title}}}_createSublayerExtensionCollection(){return new SubSublayerExtensionCollection(this)}_watchSublayerProperties(){this._watchHandles.push(this.sublayer.watch("minScale",(()=>this._notifyChange("effectiveMinScale")),!0),this.sublayer.watch("maxScale",(()=>this._notifyChange("effectiveMaxScale")),!0))}_setSublayer(e){this._sublayer=e,this._watchHandles.push(e.watch("visible",this._onSetSublayerVisible,!0)),this.supportsSublayers&&this._watchHandles.push(onCollectionPropertyChange(e,"sublayers",this._onSublayersChange,!0),watchCollectionPropertyEach(e,"sublayers","visible",this._onSetSublayersSublayerVisible,!0)),this._onSetSublayerVisible(this.sublayer.visible),"exclusive"===this.visibilityMode&&this._ensureAtMostOneChildSublayerVisible(),this._watchSublayerProperties(),this.notifyChange("sublayer"),this.notifyChange("title"),this.notifyChange("effectiveMinScale"),this.notifyChange("effectiveMaxScale"),this.notifyChange("isEffectivelyVisible")}_ensureAChildSublayerVisible(e){for(const t of this._sublayers.toArray())t!==e&&(t.visible=!1)}_ensureAtMostOneChildSublayerVisible(){this.sublayer&&this._sublayers&&this._ensureAChildSublayerVisible(this._sublayers.find((e=>e.visible)))}}let SublayerSchema=class extends Schema{constructor(e){super(),this._sublayerExtension=e}get spatialReference(){if(this._sublayerExtension.layerExtension)return this._sublayerExtension.layerExtension.schema.spatialReference}set spatialReference(e){throw new InvalidOperationError("Cannot set sublayer schema spatial reference.")}};SublayerSchema=__decorate([serializable],SublayerSchema);export{SublayerSchema};export class SubSublayerExtensionCollection extends SublayerExtensionCollectionBase{constructor(e){super(e,"sublayer.sublayers")}get _layerExtension(){return this._parent.layerExtension}add(e,t){if(checkArg("sublayerX",e).isNotMissing(),!this._parent.supportsSublayers)throw new InvalidOperationError(ERR_SUBLAYERX_NOT_SUPPORTED);e.sublayer&&this._parent.sublayer&&!this._parent.sublayer.sublayers&&(this._parent.sublayer.sublayers=[]),e.parentSublayerExtension&&e.parentSublayerExtension.sublayerExtensions.remove(e),super.add(e,t)}_onAdded(e){super._onAdded(e),e._setParentSublayerExtension(this._parent)}_onRemoved(e){super._onRemoved(e),e._setParentSublayerExtension(void 0)}}export function _assignSublayerExtensions(e,t,i){compare(e,t,{onNew:(t,s)=>{e.add(isSublayerExtension(t)?t:i(t),isSublayerRef(t)?void 0:s)},onMatch:(t,i,s,r)=>{isSublayerExtension(i)||t.assignProperties(i),s===r||isSublayerRef(i)||e.reorder(t,r)},equals:(e,t)=>isSublayerExtension(t)?t===e:!!SublayerExtension._matchesRef(e.sublayer,t.sublayer,"both")||e.id===t.id})}function isSublayer(e){return e&&"function"==typeof e.get}function isSublayerRef(e){return isSublayerExtension(e)?!!e._deferredSublayerProperties?.$ref:!isSublayer(e.sublayer)&&!!e.sublayer?.$ref}
|
package/menus/MenuItem.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare class MenuItem<TMenuItemProps extends MenuItemProperties = MenuIt
|
|
|
59
59
|
* @inheritdoc
|
|
60
60
|
*/
|
|
61
61
|
protected readonly _itemType: string;
|
|
62
|
-
|
|
62
|
+
protected _isToggled: boolean;
|
|
63
63
|
private _submenu;
|
|
64
64
|
private _iconId;
|
|
65
65
|
private _isEnabled;
|
package/package.json
CHANGED
package/portal/DrawingInfo.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type EsriCSVLayer from "@arcgis/core/layers/CSVLayer";
|
|
1
2
|
import type EsriFeatureLayer from "@arcgis/core/layers/FeatureLayer";
|
|
2
3
|
import type EsriImageryLayer from "@arcgis/core/layers/ImageryLayer";
|
|
3
4
|
import type EsriLayer from "@arcgis/core/layers/Layer";
|
|
4
5
|
import type EsriPointCloudLayer from "@arcgis/core/layers/PointCloudLayer";
|
|
5
6
|
import type EsriSceneLayer from "@arcgis/core/layers/SceneLayer";
|
|
7
|
+
import type EsriStreamLayer from "@arcgis/core/layers/StreamLayer";
|
|
6
8
|
import type EsriSublayer from "@arcgis/core/layers/support/Sublayer";
|
|
7
9
|
import { LabelingInfo } from "./LabelingInfo.js";
|
|
8
10
|
import type { PointCloudFilter } from "./PointCloudFilter.js";
|
|
@@ -14,7 +16,7 @@ export declare namespace DrawingInfo {
|
|
|
14
16
|
* @param json The layer definition JSON to apply.
|
|
15
17
|
* @param layer The Layer object to apply it to.
|
|
16
18
|
*/
|
|
17
|
-
function applyToEsriApiLayer(json: DrawingInfo, layer: EsriFeatureLayer | EsriImageryLayer | EsriSceneLayer | EsriPointCloudLayer | EsriSublayer): Promise<void>;
|
|
19
|
+
function applyToEsriApiLayer(json: DrawingInfo, layer: EsriStreamLayer | EsriCSVLayer | EsriFeatureLayer | EsriImageryLayer | EsriSceneLayer | EsriPointCloudLayer | EsriSublayer): Promise<void>;
|
|
18
20
|
/**
|
|
19
21
|
* Creates ArcGIS Portal drawing info JSON from a Layer object.
|
|
20
22
|
*
|
package/portal/DrawingInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import stableStringify from"safe-stable-stringify";import{Warning as EsriWarning}from"../support/_esriInternal.js";import{isFeatureLayer,isMapImageSublayer as isEsriSublayer,isPointCloudLayer,isSceneLayer}from"../utilities/_layers.js";import{checkArg}from"../utilities/checkArg.js";import{LabelingInfo}from"./LabelingInfo.js";import{PointCloudRenderer}from"./PointCloudRenderer.js";import{Renderer}from"./Renderer.js";export var DrawingInfo;!function(e){e.applyToEsriApiLayer=async function(e,r){checkArg("json",e).isNotMissing(),checkArg("layer",r).isNotMissing(),(isFeatureLayer(r)||isSceneLayer(r)||isEsriSublayer(r))&&(e.hasOwnProperty("labelingInfo")&&e.labelingInfo&&(r.labelingInfo=[],e.labelingInfo.forEach((e=>{r.labelingInfo.push(LabelingInfo.toEsriApiLabelClass(e))}))),e.hasOwnProperty("showLabels")&&(r.labelsVisible=e.showLabels)),e.hasOwnProperty("renderer")&&(e.renderer?isPointCloudLayer(r)?r.renderer=await PointCloudRenderer.toEsriApiPointCloudRenderer(e.renderer):r.renderer=Renderer.toEsriApiRenderer(e.renderer):r.renderer=void 0,!r.renderer&&e.renderer&&r.loadWarnings.push(new EsriWarning("renderer:unsupported",`Renderers of type '${e.renderer.type||"unknown"}' are not supported`,{definition:e.renderer}))),e.hasOwnProperty("transparency")&&(r.opacity=1-e.transparency/100)},e.fromEsriApiLayer=function(e){checkArg("layer",e).isNotMissing();const r={};return isEsriSublayer(e)&&!e.layer?.capabilities?.exportMap?.supportsDynamicLayers||(e.renderer&&(isEsriSublayer(e)&&"map-layer"===e.source.type&&e.sourceJSON?.drawingInfo?.renderer&&stableStringify(e.renderer?.toJSON())===stableStringify(Renderer.toEsriApiRenderer(e.sourceJSON?.drawingInfo?.renderer).toJSON())||(r.renderer=Renderer.fromEsriApiRenderer(e.renderer))),void 0!==e.opacity&&isEsriSublayer(e)&&(r.transparency=100*(1-e.opacity)),e.labelingInfo&&e.labelingInfo.length&&(r.labelingInfo=[],e.labelingInfo.forEach((e=>{r.labelingInfo.push(LabelingInfo.fromEsriApiLabelClass(e))}))),void 0!==e.labelsVisible&&null!==e.labelsVisible&&(r.showLabels=e.labelsVisible)),r}}(DrawingInfo||(DrawingInfo={}));
|
|
1
|
+
import stableStringify from"safe-stable-stringify";import{Warning as EsriWarning}from"../support/_esriInternal.js";import{isCSVLayer,isFeatureLayer,isMapImageSublayer as isEsriSublayer,isPointCloudLayer,isSceneLayer,isStreamLayer}from"../utilities/_layers.js";import{checkArg}from"../utilities/checkArg.js";import{LabelingInfo}from"./LabelingInfo.js";import{PointCloudRenderer}from"./PointCloudRenderer.js";import{Renderer}from"./Renderer.js";export var DrawingInfo;!function(e){e.applyToEsriApiLayer=async function(e,r){checkArg("json",e).isNotMissing(),checkArg("layer",r).isNotMissing(),(isFeatureLayer(r)||isSceneLayer(r)||isCSVLayer(r)||isStreamLayer(r)||isEsriSublayer(r))&&(e.hasOwnProperty("labelingInfo")&&e.labelingInfo&&(r.labelingInfo=[],e.labelingInfo.forEach((e=>{r.labelingInfo.push(LabelingInfo.toEsriApiLabelClass(e))}))),e.hasOwnProperty("showLabels")&&(r.labelsVisible=e.showLabels)),e.hasOwnProperty("renderer")&&(e.renderer?isPointCloudLayer(r)?r.renderer=await PointCloudRenderer.toEsriApiPointCloudRenderer(e.renderer):r.renderer=Renderer.toEsriApiRenderer(e.renderer):r.renderer=void 0,!r.renderer&&e.renderer&&r.loadWarnings.push(new EsriWarning("renderer:unsupported",`Renderers of type '${e.renderer.type||"unknown"}' are not supported`,{definition:e.renderer}))),e.hasOwnProperty("transparency")&&(r.opacity=1-e.transparency/100)},e.fromEsriApiLayer=function(e){checkArg("layer",e).isNotMissing();const r={};return isEsriSublayer(e)&&!e.layer?.capabilities?.exportMap?.supportsDynamicLayers||(e.renderer&&(isEsriSublayer(e)&&"map-layer"===e.source.type&&e.sourceJSON?.drawingInfo?.renderer&&stableStringify(e.renderer?.toJSON())===stableStringify(Renderer.toEsriApiRenderer(e.sourceJSON?.drawingInfo?.renderer).toJSON())||(r.renderer=Renderer.fromEsriApiRenderer(e.renderer))),void 0!==e.opacity&&isEsriSublayer(e)&&(r.transparency=100*(1-e.opacity)),e.labelingInfo&&e.labelingInfo.length&&(r.labelingInfo=[],e.labelingInfo.forEach((e=>{r.labelingInfo.push(LabelingInfo.fromEsriApiLabelClass(e))}))),void 0!==e.labelsVisible&&null!==e.labelsVisible&&(r.showLabels=e.labelsVisible)),r}}(DrawingInfo||(DrawingInfo={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ArcGISGeocoder_1;import{__decorate}from"tslib";import{addressToLocations,addressesToLocations,locationToAddress,suggestLocations}from"@arcgis/core/rest/locator";import{InvalidOperationError}from"../../InvalidOperationError.js";import{isFeature}from"../../ItemType.js";import{Feature,SCORE_FIELD,SCORE_FIELD_ORIGINAL,toGraphic}from"../../data/Feature.js";import{Schema}from"../../data/Schema.js";import{Field as FieldJson}from"../../portal/Field.js";import{SpatialReference as SpatialReferenceJson}from"../../portal/SpatialReference.js";import{DefaultArcGISRequestHelper}from"../../support/ArcGISRequestHelper.js";import{cancelify}from"../../support/Cancellable.js";import{serializable}from"../../support/Serializable.js";import{ReadOnlyCollection}from"../../utilities/ReadOnlyCollection.js";import{checkArg}from"../../utilities/checkArg.js";import{Collection}from"../../utilities/collection.js";import{load}from"../../utilities/esri.js";import{toPortalItem}from"../../utilities/portal.js";import{ADDRESS_FIELD,GeocodeOptions,Geocoder}from"./Geocoder.js";export{ADDRESS_FIELD,SCORE_FIELD};const ERR_SCHEMA_READ_ONLY="This schema property is read-only.",MATCHING_ADDRESS_FIELD="Match_addr";let ArcGISGeocoder=ArcGISGeocoder_1=class extends Geocoder{constructor(){super(...arguments),this._magicKeyAddressMap=new Map}get requestHelper(){return this._requestHelper||(this._requestHelper=new DefaultArcGISRequestHelper),this._requestHelper}set requestHelper(e){this._requestHelper=e}get categories(){return this._categories||(this._categories=new Collection),this._categories}get url(){return this._url}set url(e){this.updateUrl(e)}static async fromPortalItem(e,t){checkArg("portalItem",e).isNotMissing();const i=toPortalItem(e);await load(i);const s={...t};return void 0!==s.title&&null!==s.title||(s.title=i.title),s.url=i.url,new ArcGISGeocoder_1(s)}updateUrl(e){return this._url===e?Promise.resolve():(this._url=e,this.isInitialized?(async()=>{const e=await this._getGeocodeService(this.url);this._updateGeocodeProperties(e)})():Promise.resolve())}async*geocode(e,t){checkArg("address",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t},s="string"==typeof e?this._magicKeyAddressMap?.get(e):void 0,{outFields:r,outSpatialReference:o,maxResults:a,searchArea:c}=i,n={address:this._addressToAttributes(e),categories:this.categories.toArray(),countryCode:this.countryCode,outFields:r,outSpatialReference:o,maxLocations:a,searchExtent:c?.extent,forStorage:void 0,magicKey:s,location:t?.searchPoint},l=addressToLocations(this.url,n),d=await cancelify(l,t?.cancelToken);yield*d.map((e=>this._candidateToFeature(e,i)))}async count(e,t){checkArg("address",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t},{outFields:s,outSpatialReference:r,maxResults:o,searchArea:a}=i,c={address:this._addressToAttributes(e),categories:this.categories.toArray(),countryCode:this.countryCode,outFields:s,outSpatialReference:r,maxLocations:o,searchExtent:a?a.extent:void 0,forStorage:void 0,magicKey:void 0,location:t?.searchPoint},n=addressToLocations(this.url,c);return{source:this,count:(await cancelify(n,t?.cancelToken)).length}}async*batchGeocode(e,t){checkArg("addresses",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t};if(!this.capabilities.supportsBatch)throw new InvalidOperationError("Batch geocoding is not supported.");if(this._maxBatchSize&&e.length>this._maxBatchSize)throw new InvalidOperationError(`Batch geocoding is limited to ${this._maxBatchSize} addresses at a time.`);let s=0;const r={addresses:e.map((e=>this._addressToAttributes(e,s++))),categories:this.categories.toArray(),countryCode:this.countryCode,outSpatialReference:i.outSpatialReference},o=addressesToLocations(this.url,r),a=(await cancelify(o,t?.cancelToken)).map((e=>this._candidateToFeature(e,i)));for(const t of a){const i=t.attributes.get("ResultID");void 0!==i&&i>=0&&t.attributes.set(ADDRESS_FIELD,e[i]),t.attributes.delete("ResultID")}yield*a}async suggest(e,t){if(checkArg("searchText",e).isNotMissing(),await this.initialize(),!this.capabilities.supportsSuggest)throw new InvalidOperationError("Suggestions are not supported.");const i={text:e,categories:this.categories.toArray(),searchExtent:t?.searchArea?.extent,maxSuggestions:t?.maxResults,countryCode:this.countryCode,location:t?.searchPoint},s=suggestLocations(this.url,i),r=await cancelify(s,t?.cancelToken);return r.forEach((e=>this._magicKeyAddressMap.set(e.text,e.magicKey))),r.map((e=>e.text))}async reverseGeocode(e,t){checkArg("location",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t};if(!this.capabilities.supportsReverse)throw new InvalidOperationError("Reverse geocoding is not supported.");let s;try{const r=locationToAddress(this.url,{location:e,outSpatialReference:i.outSpatialReference});s=await cancelify(r,t?.cancelToken)}catch(e){if(400===e.details?.httpStatus)return;throw e}const r=this._candidateToFeature(s,i);return r.settings.parent=this.featureSettings,r.schema.parent=this.addressSchema,r}_getSerializableProperties(){return{...super._getSerializableProperties(),url:"initial",categories:{serializeModes:["initial"],deserialize:e=>{this.categories.removeAll(),this.categories.addMany(e)}},countryCode:"initial",requestHelper:{serialize:!1}}}_createSchema(){return new ArcGISGeocoderSchema}_createAddressSchema(){return new ArcGISGeocoderSchema}async _onInitialize(){if(await super._onInitialize(),!this.url)throw new Error("ArcGISGeocoder must be created with a url.");const e=await this._getGeocodeService(this.url);this._updateGeocodeProperties(e),this.assignProperties({});const t=SpatialReferenceJson.toEsriApiSpatialReference(e.spatialReference);this.schema.initialize({fields:e.candidateFields,spatialReference:t}),this.addressSchema.initialize({fields:e.addressFields,spatialReference:t})}async _getGeocodeService(e){const{data:t}=await this.requestHelper.request(e,{query:{f:"json"}});if(!t)throw new Error(`Response to request for url ${e} was invalid.`);return t}_updateGeocodeProperties(e){if(e.singleLineAddressField&&(this._singleLineAddressField=e.singleLineAddressField.name),e.locatorProperties&&(this._maxBatchSize=e.locatorProperties.MaxBatchSize),e.capabilities){const t=e.capabilities.split(",").map((e=>e.trim()));this._capabilitiesInternal=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsBatch:t.includes("Geocode"),supportsReverse:t.includes("ReverseGeocode"),supportsSuggest:t.includes("Suggest"),maxResults:void 0,supportsAttachmentEditing:!1})}else this._capabilitiesInternal=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsBatch:e.currentVersion>=10.1,supportsReverse:!0,supportsSuggest:!1,maxResults:void 0,supportsAttachmentEditing:!1})}_addressToAttributes(e,t){const i={};if("string"==typeof e)if(this._singleLineAddressField)i[this._singleLineAddressField]=e;else{const t=this.addressSchema.fields.map((e=>e.name)).filter((e=>!this.defaultAddressValues.has(e))).toArray();if(1!==t.length)throw new InvalidOperationError("Single line geocoding is not supported.");i[t[0]]=e}else{const t=isFeature(e)?toGraphic(e).attributes:e;for(const e of this.addressSchema.fields.map((e=>e.name)).toArray())e in t?i[e]=t[e]:this.defaultAddressValues.has(e)&&(i[e]=this.defaultAddressValues.get(e));if(0===Object.keys(i).length)throw new InvalidOperationError("At least one valid address field is required.")}return void 0!==t&&(i.OBJECTID=t),i}_candidateToFeature(e,t){const i=new Feature({source:this});if(e.attributes)for(const t of Object.keys(e.attributes))i.attributes.set(t,e.attributes[t]);const{address:s}=e;if("string"!=typeof s||i.attributes.has("Match_addr")&&i.attributes.get("Match_addr")){if("object"==typeof s)for(const e of Object.keys(s))i.attributes.set(e,s[e])}else s?i.attributes.set("Match_addr",s):i.attributes.set("Match_addr",Object.values(e.attributes).join(", "));return e.score&&(i.attributes.set(SCORE_FIELD,e.score),i.attributes.set(SCORE_FIELD_ORIGINAL,e.score)),i.geometry=e.location,t.outSpatialReference&&(i.schema.spatialReference=t.outSpatialReference),i}};ArcGISGeocoder=ArcGISGeocoder_1=__decorate([serializable],ArcGISGeocoder);export{ArcGISGeocoder};let ArcGISGeocoderSchema=class extends Schema{constructor(){super(),this._fieldBackingCollection=new Collection,this._fieldCollection=new ReadOnlyCollection(this._fieldBackingCollection)}get _fields(){return this._fieldCollection}get spatialReference(){return this._spatialReference}set spatialReference(e){throw new InvalidOperationError(ERR_SCHEMA_READ_ONLY)}get geometryType(){return"esriGeometryPoint"}set geometryType(e){throw new InvalidOperationError(ERR_SCHEMA_READ_ONLY)}initialize(e){if(e.fields&&(this._fieldBackingCollection.removeAll(),this._fieldBackingCollection.addMany(e.fields.map((e=>FieldJson.toEsriApiField(e))))),e.spatialReference&&(this._spatialReference=e.spatialReference,this.notifyChange("spatialReference")),!this.isModified("displayField")){let e=this.fields.find((e=>"match_addr"===e.name.toLowerCase()));e||(e=this.fields.find((e=>"address"===e.name.toLowerCase()))),e&&(this.displayField=e.name,this.notifyChange("displayField"))}}};ArcGISGeocoderSchema=__decorate([serializable],ArcGISGeocoderSchema);
|
|
1
|
+
var ArcGISGeocoder_1;import{__decorate}from"tslib";import{addressToLocations,addressesToLocations,locationToAddress,suggestLocations}from"@arcgis/core/rest/locator";import{InvalidOperationError}from"../../InvalidOperationError.js";import{isFeature}from"../../ItemType.js";import{Feature,SCORE_FIELD,SCORE_FIELD_ORIGINAL,toGraphic}from"../../data/Feature.js";import{Schema}from"../../data/Schema.js";import{Field as FieldJson}from"../../portal/Field.js";import{SpatialReference as SpatialReferenceJson}from"../../portal/SpatialReference.js";import{DefaultArcGISRequestHelper}from"../../support/ArcGISRequestHelper.js";import{cancelify}from"../../support/Cancellable.js";import{serializable}from"../../support/Serializable.js";import{ReadOnlyCollection}from"../../utilities/ReadOnlyCollection.js";import{checkArg}from"../../utilities/checkArg.js";import{Collection}from"../../utilities/collection.js";import{load}from"../../utilities/esri.js";import{toPortalItem}from"../../utilities/portal.js";import{ADDRESS_FIELD,GeocodeOptions,Geocoder}from"./Geocoder.js";export{ADDRESS_FIELD,SCORE_FIELD};const ERR_SCHEMA_READ_ONLY="This schema property is read-only.",MATCHING_ADDRESS_FIELD="Match_addr";let ArcGISGeocoder=ArcGISGeocoder_1=class extends Geocoder{constructor(){super(...arguments),this._magicKeyAddressMap=new Map}get requestHelper(){return this._requestHelper||(this._requestHelper=new DefaultArcGISRequestHelper),this._requestHelper}set requestHelper(e){this._requestHelper=e}get categories(){return this._categories||(this._categories=new Collection),this._categories}get url(){return this._url}set url(e){this.updateUrl(e)}static async fromPortalItem(e,t){checkArg("portalItem",e).isNotMissing();const i=toPortalItem(e);await load(i);const s={...t};return void 0!==s.title&&null!==s.title||(s.title=i.title),s.url=i.url,new ArcGISGeocoder_1(s)}updateUrl(e){return this._url===e?Promise.resolve():(this._url=e,this.isInitialized?(async()=>{const e=await this._getGeocodeService(this.url);this._updateGeocodeProperties(e)})():Promise.resolve())}async*geocode(e,t){checkArg("address",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t},s="string"==typeof e?this._magicKeyAddressMap?.get(e):void 0,{outFields:r,outSpatialReference:o,maxResults:a,searchArea:c}=i,n={address:this._addressToAttributes(e),categories:this.categories.toArray(),countryCode:this.countryCode,outFields:r,outSpatialReference:o,maxLocations:a,searchExtent:c?.extent,forStorage:void 0,magicKey:s,location:t?.searchPoint},l=addressToLocations(this.url,n),d=await cancelify(l,t?.cancelToken);yield*d.map((e=>this._candidateToFeature(e,i)))}async count(e,t){checkArg("address",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t},{outFields:s,outSpatialReference:r,maxResults:o,searchArea:a}=i,c={address:this._addressToAttributes(e),categories:this.categories.toArray(),countryCode:this.countryCode,outFields:s,outSpatialReference:r,maxLocations:o,searchExtent:a?a.extent:void 0,forStorage:void 0,magicKey:void 0,location:t?.searchPoint},n=addressToLocations(this.url,c);return{source:this,count:(await cancelify(n,t?.cancelToken)).length}}async*batchGeocode(e,t){checkArg("addresses",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t};if(!this.capabilities.supportsBatch)throw new InvalidOperationError("Batch geocoding is not supported.");if(this._maxBatchSize&&e.length>this._maxBatchSize)throw new InvalidOperationError(`Batch geocoding is limited to ${this._maxBatchSize} addresses at a time.`);let s=0;const r={addresses:e.map((e=>this._addressToAttributes(e,s++))),categories:this.categories.toArray(),countryCode:this.countryCode,outSpatialReference:i.outSpatialReference},o=addressesToLocations(this.url,r),a=(await cancelify(o,t?.cancelToken)).map((e=>this._candidateToFeature(e,i)));for(const t of a){const i=t.attributes.get("ResultID");void 0!==i&&i>=0&&t.attributes.set(ADDRESS_FIELD,e[i]),t.attributes.delete("ResultID")}yield*a}async suggest(e,t){if(checkArg("searchText",e).isNotMissing(),await this.initialize(),!this.capabilities.supportsSuggest)throw new InvalidOperationError("Suggestions are not supported.");const i={text:e,categories:this.categories.toArray(),searchExtent:t?.searchArea?.extent,maxSuggestions:t?.maxResults,countryCode:this.countryCode,location:t?.searchPoint},s=suggestLocations(this.url,i),r=await cancelify(s,t?.cancelToken);return r.forEach((e=>this._magicKeyAddressMap.set(e.text,e.magicKey))),r.map((e=>e.text))}async reverseGeocode(e,t){checkArg("location",e).isNotMissing(),await this.initialize();const i={...GeocodeOptions.DEFAULTS,...GeocodeOptions.fromFeatureSource(this),...t};if(!this.capabilities.supportsReverse)throw new InvalidOperationError("Reverse geocoding is not supported.");let s;try{const r=locationToAddress(this.url,{location:e,outSpatialReference:i.outSpatialReference});s=await cancelify(r,t?.cancelToken)}catch(e){if(400===e.details?.httpStatus)return;throw e}const r=this._candidateToFeature(s,i);return r.settings.parent=this.featureSettings,r.schema.parent=this.addressSchema,r}_getSerializableProperties(){return{...super._getSerializableProperties(),url:"initial",categories:{serializeModes:["initial"],deserialize:e=>{this.categories.removeAll(),this.categories.addMany(e)}},countryCode:"initial",requestHelper:{serialize:!1}}}_createSchema(){return new ArcGISGeocoderSchema}_createAddressSchema(){return new ArcGISGeocoderSchema}async _onInitialize(){if(await super._onInitialize(),!this.url)throw new Error("ArcGISGeocoder must be created with a url.");const e=await this._getGeocodeService(this.url);this._updateGeocodeProperties(e),this.assignProperties({});const t=SpatialReferenceJson.toEsriApiSpatialReference(e.spatialReference);this.schema.initialize({fields:e.candidateFields,spatialReference:t}),this.addressSchema.initialize({fields:e.addressFields,spatialReference:t})}async _getGeocodeService(e){const{data:t}=await this.requestHelper.request(e,{query:{f:"json"}});if(!t)throw new Error(`Response to request for url ${e} was invalid.`);return t}_updateGeocodeProperties(e){if(e.singleLineAddressField&&(this._singleLineAddressField=e.singleLineAddressField.name),e.locatorProperties&&(this._maxBatchSize=e.locatorProperties.MaxBatchSize),e.capabilities){const t=e.capabilities.split(",").map((e=>e.trim()));this._capabilitiesInternal=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsBatch:t.includes("Geocode"),supportsReverse:t.includes("ReverseGeocode"),supportsSuggest:t.includes("Suggest"),maxResults:void 0,supportsAttachmentEditing:!1})}else this._capabilitiesInternal=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsBatch:e.currentVersion>=10.1,supportsReverse:!0,supportsSuggest:!1,maxResults:void 0,supportsAttachmentEditing:!1})}_addressToAttributes(e,t){const i={};if("string"==typeof e)if(this._singleLineAddressField)i[this._singleLineAddressField]=e,[...this.defaultAddressValues.entries()].forEach((([e,t])=>{i[e]=t}));else{const t=this.addressSchema.fields.map((e=>e.name)).filter((e=>!this.defaultAddressValues.has(e))).toArray();if(1!==t.length)throw new InvalidOperationError("Single line geocoding is not supported.");i[t[0]]=e}else{const t=isFeature(e)?toGraphic(e).attributes:e;for(const e of this.addressSchema.fields.map((e=>e.name)).toArray())e in t?i[e]=t[e]:this.defaultAddressValues.has(e)&&(i[e]=this.defaultAddressValues.get(e));if(0===Object.keys(i).length)throw new InvalidOperationError("At least one valid address field is required.")}return void 0!==t&&(i.OBJECTID=t),i}_candidateToFeature(e,t){const i=new Feature({source:this});if(e.attributes)for(const t of Object.keys(e.attributes))i.attributes.set(t,e.attributes[t]);const{address:s}=e;if("string"!=typeof s||i.attributes.has("Match_addr")&&i.attributes.get("Match_addr")){if("object"==typeof s)for(const e of Object.keys(s))i.attributes.set(e,s[e])}else s?i.attributes.set("Match_addr",s):i.attributes.set("Match_addr",Object.values(e.attributes).join(", "));return e.score&&(i.attributes.set(SCORE_FIELD,e.score),i.attributes.set(SCORE_FIELD_ORIGINAL,e.score)),i.geometry=e.location,t.outSpatialReference&&(i.schema.spatialReference=t.outSpatialReference),i}};ArcGISGeocoder=ArcGISGeocoder_1=__decorate([serializable],ArcGISGeocoder);export{ArcGISGeocoder};let ArcGISGeocoderSchema=class extends Schema{constructor(){super(),this._fieldBackingCollection=new Collection,this._fieldCollection=new ReadOnlyCollection(this._fieldBackingCollection)}get _fields(){return this._fieldCollection}get spatialReference(){return this._spatialReference}set spatialReference(e){throw new InvalidOperationError(ERR_SCHEMA_READ_ONLY)}get geometryType(){return"esriGeometryPoint"}set geometryType(e){throw new InvalidOperationError(ERR_SCHEMA_READ_ONLY)}initialize(e){if(e.fields&&(this._fieldBackingCollection.removeAll(),this._fieldBackingCollection.addMany(e.fields.map((e=>FieldJson.toEsriApiField(e))))),e.spatialReference&&(this._spatialReference=e.spatialReference,this.notifyChange("spatialReference")),!this.isModified("displayField")){let e=this.fields.find((e=>"match_addr"===e.name.toLowerCase()));e||(e=this.fields.find((e=>"address"===e.name.toLowerCase()))),e&&(this.displayField=e.name,this.notifyChange("displayField"))}}};ArcGISGeocoderSchema=__decorate([serializable],ArcGISGeocoderSchema);
|
package/version.d.ts
CHANGED
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version="35.0
|
|
1
|
+
export const version="35.3.0";
|