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?
Solved! Go to Solution.
Lori,
It would be:
var layerDefinitions = [];
layerDefinitions[3] = "DateOn <= '" + ondate + "' AND DateOff >= '" + offdate + "'";
identifyParams.layerDefinitions = layerDefinitions;
Lori,
Are you using the IdentifyParameters.layerDefinitions array? If not then you should be.
IdentifyParameters | API Reference | ArcGIS API for JavaScript 3.19 | layerDefinitions
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.
Lori,
It would be:
var layerDefinitions = [];
layerDefinitions[3] = "DateOn <= '" + ondate + "' AND DateOff >= '" + offdate + "'";
identifyParams.layerDefinitions = layerDefinitions;
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);
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...