I have a web map with multiple feature layers loaded in it. I need the user to click on a specific layer, though I can never be sure which other layers they may or may not have turned on. I need to extract some info from the one particular layer, but because it might not be the top layer I can't always be sure it's going to be the zeroth layer they clicked on. So I'm thinking if I could get the layer name(s) that were clicked on I could then get the index of the correct layer and extract my info from there. The problem is I can't find anything in the API for hitTest or FeatureLayer or anywhere else that tells me how I can get the layer name.
var parcels = new FeatureLayer({
url: myURL1,
title: "Parcels"
});
var schools = new FeatureLayer({
url: myURL2,
title: "School Districts"
});
myMap.add(parcels);
myMap.add(schools);
myView.on("click", (event) =>
{
myView.hitTest(event).then((response) =>
{
// need something in here to grab layer name(s), but first get total # of layers
var layerCount = response.results.length;
for(var i = 0; i < layerCount; i++)
{
// how do I get the layer name(s) here?
var layername = response.results[i].???????
}
});
});