Even though I have a defiintion query on my layers, the identify includes features I don't want. In version 3.x, I was able to use layerDefinitions in the identifyParameters.
What is the equivalent in version 4.x?
Solved! Go to Solution.
Ah, sorry. That won't work in 4.13. That was introduced at 4.23 I think. Before that, we didn't have that option in the IdentifyParameters like in 3x. In recent 4x version, the sublayers need to come from a MapImageLayer as they need a layer source.
You can define the defintionExpression in a sublayer in the IdentifyParameters
You can create a MapImageLayer with your sublayers, load it, then add those sublayers to the parameters.
Hi ReneRubalcava,
That was very helpful.
This is what my parameters look like. However, it still identifies features that are hidden because of the definition expression on the MapImageLayer. At quick glance, can you tell why the definition expression doesn't appear to be working for identify? I'm using version 4.13.
// Create identify task for the specified map service
identifyTask = new IdentifyTask(urlTravelImpacts);
// Set the geometry to the location of the view click
identifyParams = new IdentifyParameters();
identifyParams.tolerance = 5;
identifyParams.layerIds = [indexBridgeRestriction, indexRoadImpact, indexRestrictionCurrent, indexRestrictionFuture, indexReferencePoints, indexIntersectionNode, indexMilepostsEstablished, indexMaintDistrict];
identifyParams.layerOption = "visible";
identifyParams.width = view.width;
identifyParams.height = view.height;
identifyParams.returnGeometry = true;
identifyParams.sublayers = [
{
id: indexBridgeRestriction
},
{
id: indexRoadImpact,
definitionExpression: "TravelImpactStartDate <= '2022/09/07' AND TravelImpactEndDate >= '2022/09/07'"
},
{
id: indexRestrictionCurrent,
definitionExpression: "TravelImpactStartDate <= '2022/09/07' AND TravelImpactEndDate >= '2022/09/07'"
},
{
id: indexRestrictionFuture,
definitionExpression: "TravelImpactStartDate <= '2022/09/07' AND TravelImpactEndDate >= '2022/09/07'"
},
{
id: indexReferencePoints
},
{
id: indexIntersectionNode
},
{
id: indexMilepostsEstablished
},
{
id: indexMaintDistrict
}
];
Ah, sorry. That won't work in 4.13. That was introduced at 4.23 I think. Before that, we didn't have that option in the IdentifyParameters like in 3x. In recent 4x version, the sublayers need to come from a MapImageLayer as they need a layer source.
I will upgrade my code to 4.24 so my map works correctly. It's odd because 4.13 was working, and now even the identify pararameter layer option = 'visible' doesn't work anymore. Even layers turned off are being identified.
Thanks again for your help! You helped me with another issue and I am so grateful to have such a wonderful Esri user community.