In the ArcGIS Server JavaScript API v4x, is it possible to simulate or programatically trigger a click on the map at a given location?
I've seen Simulate a mouse-click inside an ArcGIS Online JavaScript Application as a workaround, but in my case I'd like to trigger the view's hitTest function, which runs after the user clicks. This is a shorthand way to get all visible features on the map, without having to iterate through them all and manually run a QueryTask
.
Edit: to illustrate why this is useful, I have a map with 7 layers. When I manually click on the map, the view's hitTest
function instantly returns the attribute values of all features at the location clicked. See the response.results
object in the debugger:
There was no need for me to run 7 asynchronous QueryTask
operations then collate the responses after waiting for each to return - the view handles this without requiring a single network request. The view also handles changing layer visibility automatically, so if (eg) one layer was switched off when I clicked, then only 6 graphics would be returned, etc.
Given a known coordinate, is it possible to trigger a click at that location?