Skip to content
Types
import type { TablesMixin } from "@arcgis/core/support/TablesMixin.js";
Subclasses:
Map, GroupLayer
Since
ArcGIS Maps SDK for JavaScript 4.17

A mixin that provides properties to access tables.

Properties

PropertyTypeClass

tables

autocast Property
Type
Collection<Layer>

A collection of Layer instances that are tables saved in a Map and/or a WebMap. In order for the table(s) to be recognized as such, the FeatureLayer's FeatureLayer.isTable property must return true. A table can be created via one of the options below:

  • Referencing the URL to a table in a feature service.
  • Create a feature layer using the Layer.fromArcGISServerUrl() method and confirm that it is a table using feature layer's FeatureLayer.isTable property. This can be either a feature service or feature collection.
  • Create a feature layer using the Layer.fromPortalItem() method and confirm that it is a table using feature layer's FeatureLayer.isTable property. This can be either a feature service or feature collection.
  • Create an in-memory, non-spatial, client-side feature layer.

Beginning with 4.17, it is possible to persist non-spatial, tables in a feature service to a WebMap, although in-memory (feature collection) tables are not yet supported.

Persisting tables within a GroupLayer.tables is not yet supported. If this is needed, add them to the Map.tables and/or WebMap.tables.

Currently, only feature service feature layers are recognized. To access spatial layers, use the layers property in either Map.layers or WebMap.layers classes

See also
Examples
// This snippet shows how to add a table to a map's table collection.
// FeatureLayer.isTable = false
const featureLayer = new FeatureLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0"
});
// Add featureLayer to the map
map.add(featureLayer);
// FeatureLayer.isTable = true
const table = new FeatureLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1"
});
// In order for the table to be stored within
// the map's table collection, load it and confirm it is the right type.
table.load().then(() => {
// Add the table to the collection
map.tables.add(table);
console.log("Table is added to map's table collection");
});
// This snippet shows how to persist a table to an existing web map
// FeatureLayer.isTable = true
const table = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Crash_details_table/FeatureServer/0"
});
// Create Webmap instance
const webmap = new WebMap({
portalItem: {
id: webmapId
}
});
// When web map is ready, load the table and add it to the web map
webmap.when(() => {
table.load().then(() => {
console.log("Adding table");
// Add table to the webmap's table collection
webmap.tables.add(table);
});
});
// Call updateFrom on webmap and pass in the existing view
webmap.updateFrom(view).then(() => {
// Call saveAs (or save) on the web map
webmap.saveAs({
// autocasts as new PortalItem()
title: "New WebMap"
});
});
// This snippet shows how to add an in-memory table to a map
// Create the array of objects containing field info
const fields = [{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
},
{
name: "tree_type",
alias: "Tree type",
type: "string"
},
{
name: "species",
alias: "Species",
type: "string"
}];
// Create the array of graphics holding attribute info
const graphics = [{
attributes: {
"tree_type": "deciduous",
"species": "maple",
"ObjectID": 2
}
}, {
attributes: {
"tree_type": "coniferous",
"species": "pine",
"ObjectID": 3
}
}];
// Create the feature layer (feature collection) table
const table = new FeatureLayer({
fields: fields,
objectIdField: "ObjectID",
source: graphics
});
// Check when map is ready and load the table
map.when(() => {
table.load().then(() => {
console.log("Adding table");
map.tables.add(table);
});
});

Methods

MethodSignatureClass
findTableById(tableId: string): Layer | null | undefined

findTableById

Method
Signature
findTableById (tableId: string): Layer | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.18

Returns a table based on the given table ID.

Parameters
ParameterTypeDescriptionRequired
tableId

The ID assigned to the table.

Returns
Layer | null | undefined

Returns the requested table object.