Simple question(s) alert ! (Although some of you may find it vague or missing more detailed code. Unfortunately, I cannot paste all my code here.)
Why would hitTest() only return basemap hits as a result when I have several layers in my map? Do layers from a webmap brought into your app as Portal item work differently from those that are added as layers (Featurelayer/MapImageLayer) via URL?
I recently started transitioning from JSAPI 3.x (WAB-DE stuff) to 4.x (4.30) and might be stuck in some legacy way of thinking.
When I do this:
view.on("click", (event)=> {
view.hitTest(event).then((response) => {
// Hoping for some results from the layers in the map
// but response.results include only the basemap.
console.log(response.results.length) // = 1
});
});
When I try with options, and specifically list one of the layers in the map, I get the same result.
view.on("click", (event)=> {
opts = { include: interesting_layer};
view.hitTest(event,opts).then((response) => {
//Hoping for some results from the layers in the map;
//But no!
console.log(response.results.length) // still = 1
});
});
Where does interesting_layer come from? I currently loop through webmap layers once view has loaded and assign some names to key layers I want to interact with later.
var interesting_layer;
view.when(function() {
//The following is another simplified version of what's actually
//defined in another function elsewhere
webmap.layers.forEach(lyr => {
if (lyr.title == 'layer_of_interest')
{ interesting_layer = lyr }
});