Select to view content in your preferred language

mapview.hitTest doesn't return results if opacity is set

3064
14
10-02-2017 05:04 PM
JackFairfield
Frequent Contributor

Why doesn't the mapview.hitTest method return any results?

Consider the simple example below:

If you modify this sample:

Access features with pointer events | ArcGIS API for JavaScript 4.5 

and add the opacity property to the feature layer like this

...

var layer = new FeatureLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Hurricanes/MapServer/1",
opacity: .4,
outFields: ["*"]
});

...

The hit test response will not contain and values in the results array.

Here is a jsbin link showing what I am talking about:

JS Bin - Collaborative JavaScript Debugging 

Tags (2)
0 Kudos
14 Replies
DavidColey
MVP Regular Contributor

Thanks for the info on this Thomas et al, I thought I was going crazy.  I'm hoping the highlight for 2D will be available soon as well, since hitTest only works on the top-most feature

0 Kudos
JackFairfield
Frequent Contributor

Just to confirm.  This is resolved when using the 4.6 version of the api.

0 Kudos
DavidColey
MVP Regular Contributor

Regardless that the API Reference

Popup | API Reference | ArcGIS API for JavaScript 4.6 

still says only works in 3d?

0 Kudos
JackFairfield
Frequent Contributor

You are referencing something unrelated.  There is a hitTest method in both MapViews and SceneViews.  The sample should work in 2d and 3d.

MapView | API Reference | ArcGIS API for JavaScript 4.6 

0 Kudos
DavidColey
MVP Regular Contributor

Sorry about that, yes of course. For some reason I was thinking hightlightSymbol

0 Kudos