Weird behavior from hit test on mouse move

741
3
Jump to solution
07-30-2019 10:01 AM
BrianVan_Nostrand
New Contributor III

Hi all,

I'm trying to write an app that will allow users to move through a series of steps to route through a road network using a restricted workflow. Anyway, part of what I'm trying to do is have the user mouse over lines, select one by clicking on it, then expose all of the intersections along that route to allow the user to click an intersection, then choose the next route to continue on and so on. 

Part of the workflow is to use hit test when the mouse is moved within the view to identify which line segment they are hovering over, then zoom to that line on a click event, exposing its intersections at the same time. So far I've come up with this:

 When the click event fires, though, it's showing multiple responses. Specifically, it's showing as many responses as there have been hit tests performed, cumulatively.

For instance, in the following screenshot, you see from script.js line 104, 3 instances of the hit test event firing (it prints the number of results contained in the hit test response), then 3 click responses.

Anyone know why this is happening? Code is attached.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Brian,

   You are seeing that many responses because you are adding that many event watchers on line 105. Each time a hittest finds a graphic you add a view.on("pointer-down". You need to add the pointer-down event only once outside of your hit test result function.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Brian,

   You are seeing that many responses because you are adding that many event watchers on line 105. Each time a hittest finds a graphic you add a view.on("pointer-down". You need to add the pointer-down event only once outside of your hit test result function.

BrianVan_Nostrand
New Contributor III

Let me know when you're thinking about retiring so I can short ESRI stock.

0 Kudos
BrianVan_Nostrand
New Contributor III

Thanks, you got it.

0 Kudos