Select to view content in your preferred language

Identify Results Include features excluded by definition query

2018
5
Jump to solution
01-26-2017 11:31 AM
LoriEmerson_McCormack
Regular Contributor

I am using the ArcGISDynamicMapServiceLayer to load my layers into the map in ArcGIS API for JavaScript 3.19.

I have set up the IdentifyTask, and it works great except for one problem.  I allow the end-user to search on a date range which sets a definition query to only display those features.  However, the identify popup includes those features that are being excluded using the definition query. 

How do I get an Identify popup for only those features that are visible because of the definition query?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lori,

It would be:

var layerDefinitions = [];
layerDefinitions[3] = "DateOn <= '" + ondate + "' AND DateOff >= '" + offdate + "'";‍‍
identifyParams.layerDefinitions = layerDefinitions;

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Lori,

   Are you using the IdentifyParameters.layerDefinitions array? If not then you should be.

IdentifyParameters | API Reference | ArcGIS API for JavaScript 3.19 | layerDefinitions 

LoriEmerson_McCormack
Regular Contributor

Good idea!

When I try setting the identify parameter layer definition,

identifyParams.layerDefinitions[3] = "DateOn <= '" + ondate + "' AND DateOff >= '" + offdate + "'";

I get an error

"0x800a138f - JavaScript runtime error: Unable to set property '3' of undefined or null reference"

So, I found on another post to try setting the layer definition like this:

identifyParams.layerDefinitions = { "3": "DateOn <= '" + ondate + "' AND DateOff >= '" + offdate + "'" };

I do not get an error, but the identify layer definition is not getting set.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lori,

It would be:

var layerDefinitions = [];
layerDefinitions[3] = "DateOn <= '" + ondate + "' AND DateOff >= '" + offdate + "'";‍‍
identifyParams.layerDefinitions = layerDefinitions;
0 Kudos
LoriEmerson_McCormack
Regular Contributor

Thank you.  It is similar to how I set up the regular definition query. 

var layerDefinitions = [];

layerDefinitions[0] = "bridge_symbol = 'weight restr'";

allTravelImpactsLayer.setLayerDefinitions(layerDefinitions);

Skyler
by
Occasional Contributor

For anyone encountering this issue when identifying against a MapImageLayer in Version 4.x of the ArcGIS Maps SDK for JavaScript, the sublayers property of IdentifyParameters needs to be specified, as explained here: https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/what-is-the-layerdefinitions-equi...

0 Kudos