Prior to Components, I was able to use mapView.on("click"). If a user clicked on the Zoom/Nav buttons, everything works as expected -- the tool works and the mapView.hitTest is ignored.
Migrating to Components, I'm getting '.on' is not a function. But if replace this method with 'addEventListener', then the hitTest is called even when the user clicks a Calcite tool positioned over the map.
There's probably an obvious programming pattern I'm overlooking -- but just in case it is more involved, I've thrown together a CodePen to show the difference I'm seeing (... the code is only printing to Console, for now)
hitTest_noComponent
hitTest_Components
Is there a different event, or a different method for the event I should be using with Components?
A way in the hitTest to check if a Calcite tool was clicked?
Thanks in advance!
Solved! Go to Solution.
Hi @D_Atkins ,
Try using arcgisViewClick instead on the `click` event.
https://codepen.io/sagewall/pen/XJmLbQQ?editors=1000
Hi @D_Atkins ,
Try using arcgisViewClick instead on the `click` event.
https://codepen.io/sagewall/pen/XJmLbQQ?editors=1000
@Sage_Wall If you have a mapimagelayer, then it will still show "No feature hit" in the console. hittest works for featurelayers. How can you modify the script to show hit featureLayer/no feature hit if you are using a feature layer and a mapimagelayer.
Hi @LefterisKoumis , your right with HitTest isn't supported for server based layers like MapImageLayer. You will need to use identify with MapImageLayer. This is a sample that shows how to use identify.
https://developers.arcgis.com/javascript/latest/sample-code/identify/
Thanks @Sage_Wall
To add, the Custom Event returned by 'arcgisViewClick' is slightly different from the 'click' event -- devs may need to dig into event.detail to access the users screenPoint.