Select to view content in your preferred language

Create dynamic sublayer in MapImageLayer using a join-table with a query-table

476
0
03-02-2022 03:16 PM
GiovanniPopulis
Emerging Contributor

As the title suggests, I am currently attempting to create a dynamic sublayer for a MapImageLayer using a join-table method. For the leftTableSource I have a simple polyline layer, and on the rightTableSource I have a data-layer being created from a query-table.

I can create a table-join if I set the rightTableSource as a table rather than a query-table, but that doesn't allow me to run the query features I need to filter duplicate occurrences dynamically. The fact that the join-table works with a table vs a query-table makes me think something is wrong in the syntax setting up the join.

For reference the data being reference in the query-table is in a registered dynamic workspace and the db behind the services is running in postgres.

Does anyone see anything obviously wrong in this code?

 

I replaced some of our private information with <...>.
The variable 'where' is assigned previous to layer being created.

 

let layer = new MapImageLayer({
	url: <url to our MapServer>,
	sublayers: [{
		id: 0,
		renderer: this.Global.Accessor.visuals.classBreaksRenderer,
		definitionExpression: where,
		opacity: 1,
		source: {
			type: "data-layer",
			dataSource: {
				type: "join-table",
				leftTableSource: {
					type: "map-layer",
					mapLayerId: 1
				},
				rightTableSource: {
					type: "data-layer",
					dataSource: {
						type: "query-table",
						workspaceId: <workspaceName>,
						dataSourceName: <dataSourceName>,
						query: `SELECT distinct segmentid, COUNT(collision_id) AS cnt, borough, zip_code FROM <dataSourceName> WHERE ${where} GROUP BY segmentid, borough, zip_code`
					}
				},
				leftTableKey: "segmentid",
				rightTableKey: "segmentid",
				joinType: "left-outer-join"
			}
		}
	}]
});

 

 

 

0 Kudos
0 Replies