MapImageLayer hitTest

1342
4
09-17-2023 08:02 PM
Wade
by
Occasional Contributor

MapImageLayer is faster but there seems to be no way to use hitTest.How to get the feature data of the layer when adding hitTest when using MapImageLayer? Or just use Feature Layer for query?

 

 

 

0 Kudos
4 Replies
Sage_Wall
Esri Regular Contributor

Hi @Wade, with map image layers it's probably easier to use the identify class rather than hit test.  This is a sample that shows how to use the results from identify to create custom popups.

0 Kudos
Wade
by
Occasional Contributor

Hi @Sage_Wall , thank you for your answer.I would like to ask, when using MapImageLayer, identify clicks on the feature, how can I make the data in MapImageLayer have a highlight display?

0 Kudos
Sage_Wall
Esri Regular Contributor

Hi @Wade , MapImageLayer's work a little differently than the layers that support layer views, hit tests and highlighting.  For a replacement for highlighting with MapImageLayer I'd suggest creating a GraphicsLayer and adding it to the map.  Then with the feature returned from the Identify you can add a graphic to the GraphicsLayer.  You'll also need to set the IdentifyParameters to return the geometry.  I wrote a quick codepen that shows how this can be done, by modifying our normal Identify sample to add a graphic.  I hope this helps, although MapImageLayers can draw faster, they do have trade offs compared to using FeatureLayers.

https://codepen.io/sagewall/pen/ExGQLGJ?editors=1010

0 Kudos
Wade
by
Occasional Contributor

Thank you so much

0 Kudos