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?
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.
https://codepen.io/odoe/pen/qBYbOyG?editors=1000
You can define the defintionExpression in a sublayer in the IdentifyParameters
https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-IdentifyParameters.html#sublayers
You can create a MapImageLayer with your sublayers, load it, then add those sublayers to the parameters.
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source
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 serviceidentifyTask = new IdentifyTask(urlTravelImpacts);
// Set the geometry to the location of the view clickidentifyParams = 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}];
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.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.