Select to view content in your preferred language

Clarification on 4.23 hitTest return value

3066
11
Jump to solution
03-25-2022 08:04 AM
james-rae
Occasional Contributor

My apps need to figure out the top-most feature under the mouse pointer, so the latest hitTest update has required me to fiddle around with things. The documentation doesn't mention anything about the order of HitTestResults in the array (or I'm blind, it happens lol ).

Doing some console logging, I think I see the pattern but want to clarify (and request the documentation be updated).

It appears to me the graphics in the result array are order by layers, top-most to bottom-most, but graphics belonging to the same layer are ordered bottom-most to top-most.

So for example, if I have a pile of overlapping features from layers BL (bottom layer) and TL (top layer), my result array of graphics looks something like

 

[ TL_lowest, TL_middle, TL_highest, BL_lowest, BL_highest ]

 

Can anyone in the know confirm? Much obliged.

Tags (1)
0 Kudos
11 Replies
EirikH
by
Regular Contributor

Our case is that we display lines in our map with only 1-2 pixel thickness, and they are quite hard for users to click. We have refactored our code to not use hittest anymore (we run normal geometry queries against each layer that is a buffer around the clickpoint).

0 Kudos
mgeorge
Esri Contributor

@EirikH sorry for the delay in getting back to you. For your use case, is the map on mobile, desktop or both? And which version of the API? 

0 Kudos