import { ExtensibleUnion } from 'apprt-core/Types'; import Basemap from '@arcgis/core/Basemap'; import Ground from '@arcgis/core/Ground'; import BingMapsLayer from '@arcgis/core/layers/BingMapsLayer'; import CSVLayer from '@arcgis/core/layers/CSVLayer'; import ElevationLayer from '@arcgis/core/layers/ElevationLayer'; import FeatureLayer from '@arcgis/core/layers/FeatureLayer'; import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer'; import GeoRSSLayer from '@arcgis/core/layers/GeoRSSLayer'; import GroupLayer from '@arcgis/core/layers/GroupLayer'; import ImageryLayer from '@arcgis/core/layers/ImageryLayer'; import ImageryTileLayer from '@arcgis/core/layers/ImageryTileLayer'; import IntegratedMeshLayer from '@arcgis/core/layers/IntegratedMeshLayer'; import KMLLayer from '@arcgis/core/layers/KMLLayer'; import Layer from '@arcgis/core/layers/Layer'; import MapImageLayer from '@arcgis/core/layers/MapImageLayer'; import OGCFeatureLayer from '@arcgis/core/layers/OGCFeatureLayer'; import OpenStreetMapLayer from '@arcgis/core/layers/OpenStreetMapLayer'; import SceneLayer from '@arcgis/core/layers/SceneLayer'; import BuildingSceneLayer from '@arcgis/core/layers/BuildingSceneLayer'; import PointCloudLayer from '@arcgis/core/layers/PointCloudLayer'; import VoxelLayer from '@arcgis/core/layers/VoxelLayer'; import StreamLayer from '@arcgis/core/layers/StreamLayer'; import TileLayer from '@arcgis/core/layers/TileLayer'; import VectorTileLayer from '@arcgis/core/layers/VectorTileLayer'; import WebTileLayer from '@arcgis/core/layers/WebTileLayer'; import WFSLayer from '@arcgis/core/layers/WFSLayer'; import WMSLayer from '@arcgis/core/layers/WMSLayer'; import WMTSLayer from '@arcgis/core/layers/WMTSLayer'; /** * Provides services to create layers and other associated map items * from configuration objects. * * @module */ interface LayerTypesLookup { GROUP: [GroupLayer, __esri.GroupLayerProperties]; AGS_TILED: [TileLayer, __esri.TileLayerProperties]; AGS_DYNAMIC: [MapImageLayer, __esri.MapImageLayerProperties]; AGS_FEATURE: [FeatureLayer, __esri.FeatureLayerProperties]; AGS_IMAGE: [ImageryLayer, __esri.ImageryLayerProperties]; AGS_IMAGERYTILE: [ImageryTileLayer, __esri.ImageryTileLayerProperties]; AGS_INTEGRATEDMESH: [IntegratedMeshLayer, __esri.IntegratedMeshLayerProperties]; AGS_VECTORTILE: [VectorTileLayer, __esri.VectorTileLayerProperties]; AGS_ELEVATION: [ElevationLayer, __esri.ElevationLayerProperties]; AGS_SCENE: [SceneLayer, __esri.SceneLayerProperties]; AGS_BUILDING: [BuildingSceneLayer, __esri.BuildingSceneLayerProperties]; AGS_POINTCLOUD: [PointCloudLayer, __esri.PointCloudLayerProperties]; AGS_VOXEL: [VoxelLayer, __esri.VoxelLayerProperties]; AGS_STREAM: [StreamLayer, __esri.StreamLayerProperties]; WFS: [WFSLayer, __esri.WFSLayerProperties]; WMS: [WMSLayer, __esri.WMSLayerProperties]; WMTS: [WMTSLayer, __esri.WMTSLayerProperties]; CSV: [CSVLayer, __esri.CSVLayerProperties]; KML: [KMLLayer, __esri.KMLLayerProperties]; OSM: [OpenStreetMapLayer, __esri.OpenStreetMapLayerProperties]; WEBTILE: [WebTileLayer, __esri.WebTileLayerProperties]; BING_MAPS: [BingMapsLayer, __esri.BingMapsLayerProperties]; GEOJSON: [GeoJSONLayer, __esri.GeoJSONLayerProperties]; GEORSS: [GeoRSSLayer, __esri.GeoRSSLayerProperties]; OGC_FEATURE: [ OGCFeatureLayer, __esri.OGCFeatureLayerProperties & { /** Maximum number of features to fetch in a single request. */ limit?: number; } ]; } /** * Extension properties implemented by map.apps for all layer types. */ interface ExtendedLayerProperties { /** * Whether to expand a layer and show all its children in toc. */ initiallyExpandedInToc?: boolean; } type LayerClassForType = LayerTypesLookup[K][0]; type LayerPropertiesForType = LayerTypesLookup[K][1] & ExtendedLayerProperties; /** * Well known layer types supported by the {@link LayerFactory}. */ type WellKnownLayerType = keyof LayerTypesLookup; /** * The type of a new layer. * * This is either a {@link WellKnownLayerType} or a custom layer type. * Custom layer types must be registered with the {@link LayerFactory} before they can be used. */ type LayerType = ExtensibleUnion; /** * Properties supported by a group layer. */ type GroupLayerProperties = LayerPropertiesForType<"GROUP">; /** * Factory for layer types. */ interface LayerTypeFactory { /** * Esri type of the layer produced e.g. "web-tiled". * Transports the value of the layerInstance.type property */ esriType?: string; /** * Creates instances of layers of a certain type. */ create(opts: Record): Promise<{ instance: any; }> | { instance: any; }; } /** * Creates instances of layers of different types. * * Use service name `"map-config-api.LayerFactory"` to inject an instance of this class. */ interface LayerFactory { /** * Returns the currently available type names. */ getTypeNames(): LayerType[]; /** * Returns a mapping from layer type to esri layer type name. */ getTypeMapping(): Record; /** * Create a layer of given type. * * @param type The kind of layer. * @param options Options that will be passed during layer construction. * @returns A promise which will resolve to `{instance: Layer}`. */ createLayer(type: Type, options: LayerPropertiesForType): Promise<{ instance: LayerClassForType; }>; /** * Second overload for layer types that are not statically known. */ createLayer(type: LayerType, options: Record): Promise<{ instance: Layer; }>; /** * Creates a GroupLayer. * * @param opts options of group layer * @returns A promise which resolves to `{instance: GroupLayer}` */ createGroupLayer(opts: GroupLayerProperties): Promise<{ instance: GroupLayer; }>; } type LayerPropertiesWithType = { type: Type; } & LayerPropertiesForType; type TypedLayerProperties = { [P in WellKnownLayerType]: LayerPropertiesWithType

; }[WellKnownLayerType]; /** * Specifies properties for the construction of a new layer. */ type LayerProperties = TypedLayerProperties | { type: LayerType; [prop: string]: any; }; /** * Contains properties for the construction of a new basemap. */ interface BasemapConfigObject { /** * A well known Basemap id, such as `"streets-vector"`. * * Cannot be combined with {@link baseLayers} or {@link style}. */ id?: string; /** @deprecated Use {@link baseLayers} instead. */ layers?: LayerProperties[]; /** * Layers to use when constructed the new base map. * * Cannot be combined with {@link id} or {@link style}. */ baseLayers?: LayerProperties[]; /** * Basemap style to use when constructing the new basemap. * * Cannot be combined with {@link id} or {@link baseLayers}. */ style?: __esri.BasemapStyleProperties; /** * Optional title for the new Basemap. */ title?: string; } /** * Additional Basemap properties that will be merged into the new basemap object. */ type BasemapParserOptions = __esri.BasemapProperties; /** * Parses Basemap configurations. * * Use service name `"map-config-api.BasemapConfigParser"` to inject an instance of this class. */ interface BasemapConfigParser { /** * Parses a basemap configuration. * * @param config See examples. * @param options Additional properties that will be merged into the basemap instance, e.g. `title`. * * @returns A promise which resolves to `{instance: basemap}`. * @example * // string of well-known basemap * const result = await configParser.parse("streets", { title: 'Streets' }); * // result instance is @arcgis/core/Basemap, the well-known streets basemap, with custom title * * @example * // string of well-known basemap * const result = await configParser.parse({ id: "streets" }); * // result instance is @arcgis/core/Basemap, the well-known streets basemap * * @example * // config object with custom layer * const result = await configParser.parse({ * title: "My Basemap", * baseLayers: [{ * "url": "https://myarcgis.com/arcgis/rest/services/MyService/MapServer", * "type": "AGS_TILED" * }] * }); * // result instance is @arcgis/core/Basemap, with a custom layer * * @example * // config object with custom layer, but shorter * const result = await configParser.parse({ * "url": "https://myarcgis.com/arcgis/rest/services/MyService/MapServer", * "type": "AGS_TILED" * }) * // result instance is @arcgis/core/Basemap, with a custom layer * * @example * // config object with custom layers, but shorter * const result = await configParser.parse([{ * "url": "https://myarcgis.com/arcgis/rest/services/MyService/MapServer", * "type": "AGS_TILED" * }, * { * "url": "https://myarcgis.com/arcgis/rest/services/OtherService/MapServer", * "type": "AGS_TILED" * }]) * // result instance is @arcgis/core/Basemap, with two custom layers */ parse(config: string | LayerProperties | LayerProperties[] | BasemapConfigObject, options?: BasemapParserOptions): Promise<{ instance: Basemap; }>; } /** * Parses layer configurations. * * Use service name `"map-config-api.LayerConfigParser"` to inject an instance of this class. */ interface LayerConfigParser { /** * Parses array of layer configurations. * * @param configs An array of configuration items. * @returns A promise which resolves to an array of layer instances. * @example * configParser.parse([{ * "visible": true, * "url": "http://water.discomap.eea.europa.eu/arcgis/rest/services/BathingWater/BathingWater_Dyna_WM/MapServer", * "type": "AGS_DYNAMIC", * "sublayers": ["*"] * }]).then((layers) => { * // layers[0] is instance of @arcgis/core/layers/MapImageLayer * }); */ parse(configs: LayerProperties[]): Promise; } /** * Construction parameters supported by an elevation layer. */ type ElevationLayerProperties = LayerPropertiesWithType<"AGS_ELEVATION">; /** * Construction properties for a ground instance. */ type GroundProperties = Omit<__esri.GroundProperties, "layers"> & { layers?: ElevationLayerProperties[]; }; /** * Parses ground configurations into instances of `@arcgis/core/Ground`. * * Use service name `"map-config-api.GroundConfigParser"` to inject an instance of this class. */ interface GroundConfigParser { /** * Parses ground layer configurations. * * @param config Configurations for the ground layer. * @returns A promise which resolves to { instance : groundlayer {. * * @example * // well known ground name * configParser.parse("world-elevation").then((result) => { * // result.instance is @arcgis/core/Ground * }); * * @example * // array of elevation layers * configParser.parse([{ * "url": "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer", * "type": "AGS_ELEVATION" * }]).then((result) => { * // result.instance is @arcgis/core/Ground * }); * * @example * // ground config object, the only way to add additional properties, like "title" * configParser.parse({ * title: "My Ground Name", * layers: [{ * "url": "http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer", * "type": "AGS_ELEVATION" * }, { * "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/MtBaldy_Elevation/ImageServer", * "type": "AGS_ELEVATION" * }] * }).then((result) => { * // result.instance is @arcgis/core/Ground * }); */ parse(config: string | ElevationLayerProperties[] | GroundProperties): Promise<{ instance: Ground; }>; } export type { BasemapConfigObject, BasemapConfigParser, BasemapParserOptions, ElevationLayerProperties, ExtendedLayerProperties, GroundConfigParser, GroundProperties, GroupLayerProperties, LayerClassForType, LayerConfigParser, LayerFactory, LayerProperties, LayerPropertiesForType, LayerType, LayerTypeFactory, WellKnownLayerType };