@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
159 lines (157 loc) • 7.19 kB
TypeScript
import type PortalItem from "../../portal/PortalItem.js";
import type { PortalItemProperties } from "../../portal/PortalItem.js";
export interface PortalLayerProperties {
/**
* The portal item from which the layer is loaded. If the portal item references
* a feature or scene service, then you can specify a single layer
* to load with the layer's `layerId` property.
*
* > [!WARNING]
* >
* > **Loading non-spatial tables**
* >
* > Non-spatial tables can be loaded from service items hosted in ArcGIS Online and ArcGIS Enterprise.
* > This only applies to:
* > - [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) if the layer's [isTable](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#isTable) returns `true` at version 4.17.
* > - [SubtypeGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/) if the layer's [isTable](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/#isTable) returns `true` at version 4.32.
*
* @example
* // While this example uses FeatureLayer, this same pattern can be
* // used for other layers that may be loaded from portalItem ids.
* const layer = new FeatureLayer({
* portalItem: { // autocasts as new PortalItem()
* id: "caa9bd9da1f4487cb4989824053bb847"
* } // the first layer in the service is returned
* });
* @example
* // Set hostname when using an on-premise portal (default is ArcGIS Online)
* // esriConfig.portalUrl = "http://myHostName.esri.com/arcgis";
*
* // While this example uses FeatureLayer, this same pattern can be
* // used for SceneLayers.
* const layer = new FeatureLayer({
* portalItem: { // autocasts as new PortalItem()
* id: "8d26f04f31f642b6828b7023b84c2188"
* },
* // loads the third item in the given feature service
* layerId: 2
* });
* @example
* // Initialize GeoJSONLayer by referencing a portalItem id pointing to geojson file.
* const layer = new GeoJSONLayer({
* portalItem: new PortalItem({
* id: "81e769cd7031482797e1b0768f23c7e1",
* // optionally define the portal, of the item.
* // if not specified, the default portal defined is used.
* // see https://developers.arcgis.com/javascript/latest/references/core/config/#portalUrl
* portal: new Portal({
* url: "https://jsapi.maps.arcgis.com/"
* })
* }
* });
* @example
* // This snippet loads a table hosted in ArcGIS Online.
* const table = new FeatureLayer({
* portalItem: { // autocasts as esri/portal/PortalItem
* id: "123f4410054b43d7a0bacc1533ceb8dc"
* }
* });
*
* // Before adding the table to the map, it must first be loaded and confirm it is the right type.
* table.load().then(() => {
* if (table.isTable) {
* map.tables.add(table);
* }
* });
* @example
* // While this example uses FeatureLayer, this same pattern can be
* // used for other layers that may be loaded from portalItem ids.
* const layer = new FeatureLayer({
* portalItem: { // autocasts as esri/portal/PortalItem
* id: "caa9bd9da1f4487cb4989824053bb847",
* // Set an API key to access a secure portal item configured with API key authentication.
* apiKey: "APIKEY"
* }
* });
*/
portalItem?: PortalItemProperties | null;
}
/** PortalLayer is a mixin that adds the [portalItem](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/PortalLayer/#portalItem) property to layers that can be loaded from a portal item. */
export abstract class PortalLayer {
constructor(...args: any[]);
/**
* The portal item from which the layer is loaded. If the portal item references
* a feature or scene service, then you can specify a single layer
* to load with the layer's `layerId` property.
*
* > [!WARNING]
* >
* > **Loading non-spatial tables**
* >
* > Non-spatial tables can be loaded from service items hosted in ArcGIS Online and ArcGIS Enterprise.
* > This only applies to:
* > - [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) if the layer's [isTable](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#isTable) returns `true` at version 4.17.
* > - [SubtypeGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/) if the layer's [isTable](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/#isTable) returns `true` at version 4.32.
*
* @example
* // While this example uses FeatureLayer, this same pattern can be
* // used for other layers that may be loaded from portalItem ids.
* const layer = new FeatureLayer({
* portalItem: { // autocasts as new PortalItem()
* id: "caa9bd9da1f4487cb4989824053bb847"
* } // the first layer in the service is returned
* });
* @example
* // Set hostname when using an on-premise portal (default is ArcGIS Online)
* // esriConfig.portalUrl = "http://myHostName.esri.com/arcgis";
*
* // While this example uses FeatureLayer, this same pattern can be
* // used for SceneLayers.
* const layer = new FeatureLayer({
* portalItem: { // autocasts as new PortalItem()
* id: "8d26f04f31f642b6828b7023b84c2188"
* },
* // loads the third item in the given feature service
* layerId: 2
* });
* @example
* // Initialize GeoJSONLayer by referencing a portalItem id pointing to geojson file.
* const layer = new GeoJSONLayer({
* portalItem: new PortalItem({
* id: "81e769cd7031482797e1b0768f23c7e1",
* // optionally define the portal, of the item.
* // if not specified, the default portal defined is used.
* // see https://developers.arcgis.com/javascript/latest/references/core/config/#portalUrl
* portal: new Portal({
* url: "https://jsapi.maps.arcgis.com/"
* })
* }
* });
* @example
* // This snippet loads a table hosted in ArcGIS Online.
* const table = new FeatureLayer({
* portalItem: { // autocasts as esri/portal/PortalItem
* id: "123f4410054b43d7a0bacc1533ceb8dc"
* }
* });
*
* // Before adding the table to the map, it must first be loaded and confirm it is the right type.
* table.load().then(() => {
* if (table.isTable) {
* map.tables.add(table);
* }
* });
* @example
* // While this example uses FeatureLayer, this same pattern can be
* // used for other layers that may be loaded from portalItem ids.
* const layer = new FeatureLayer({
* portalItem: { // autocasts as esri/portal/PortalItem
* id: "caa9bd9da1f4487cb4989824053bb847",
* // Set an API key to access a secure portal item configured with API key authentication.
* apiKey: "APIKEY"
* }
* });
*/
get portalItem(): PortalItem | null | undefined;
set portalItem(value: PortalItemProperties | null | undefined);
}