MapImageLayer - dynamic data layer with query table

This sample demonstrates how to add a sublayer with features from a query table data source in a MapImageLayer.

The QueryTableDataSource can be used to dynamically render a spatial table that doesn't have an associated geodatabase. It can also be used for complex SQL queries, such as those that perform joins to non-spatial tables containing multiple records that match to features in the spatial table. The query parameter may be used to filter the table so that only a one-to-one relationship exists between records in the table to those in the spatial table.

The table or feature class must exist in a registered dynamic workspace on your Map Server. In this sample, we create a MapImageLayer from a map service containing feature classes registered to a dynamic workspace. These feature classes are not service layers. Therefore we need to dynamically render them if you want to visualize them in the view. To do so, you must set the source property of the sublayer as a data-layer type and set the dataSource to query-table.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
source: {
  type: "data-layer",
  dataSource: {
    type: "query-table",
    workspaceId: "MyDatabaseWorkspaceIDSSR2",
    // Select all the records in the Places feature class
    // where the class of the feature is 'city'
    query: "SELECT * FROM ss6.gdb.Places WHERE class = 'city'",
    spatialReference: { wkid: 4326 },
    geometryType: "point",
    oidFields: "objectid"
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.