Select to view content in your preferred language

Using Components with hitTest: 'click' on Calcite Buttons registers as hitTest in underlying Map

721
4
Jump to solution
09-12-2025 08:08 AM
D_Atkins
Frequent Contributor

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!

0 Kudos
1 Solution

Accepted Solutions
4 Replies
Sage_Wall
Esri Regular Contributor
LefterisKoumis
Frequent Contributor

@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.

0 Kudos
Sage_Wall
Esri Regular Contributor

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/

D_Atkins
Frequent Contributor

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.

0 Kudos