<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get layer name from clicking on layer feature in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302109#M81478</link>
    <description>&lt;P&gt;Thanks! But the correct solution was to use&amp;nbsp;response.results[i].layer.&lt;STRONG&gt;title&lt;/STRONG&gt;, not name.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 16:29:48 GMT</pubDate>
    <dc:creator>Jackson_CountyMissouri</dc:creator>
    <dc:date>2023-06-22T16:29:48Z</dc:date>
    <item>
      <title>Get layer name from clicking on layer feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302085#M81472</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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) =&amp;gt;
{
    myView.hitTest(event).then((response) =&amp;gt;
    {
        // 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 &amp;lt; layerCount; i++)
        {
             // how do I get the layer name(s) here?
             var layername = response.results[i].???????
        }
    });
});&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 22 Jun 2023 16:00:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302085#M81472</guid>
      <dc:creator>Jackson_CountyMissouri</dc:creator>
      <dc:date>2023-06-22T16:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer name from clicking on layer feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302093#M81475</link>
      <description>&lt;P&gt;response.results[i].layer - will return the layer the feature belongs to and you can get the layer title from there.&lt;/P&gt;&lt;P&gt;Hittest returns ViewHit results:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#ViewHit" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#ViewHit&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are working with features from a layer then your view hit result is graphic hit and graphic hit returns the layer to which the feature belongs to:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#GraphicHit" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#GraphicHit&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 16:07:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302093#M81475</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-06-22T16:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer name from clicking on layer feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302100#M81476</link>
      <description>&lt;P&gt;Thanks, but when I do that it just returns&amp;nbsp;"[object Object]"&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 16:17:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302100#M81476</guid>
      <dc:creator>Jackson_CountyMissouri</dc:creator>
      <dc:date>2023-06-22T16:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer name from clicking on layer feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302106#M81477</link>
      <description>&lt;P&gt;Yes it will return layer object... FeatureLayer has name property so to get the name you do&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;response.results[i].layer.name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Take a look at the FeatureLayer properties from here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#properties-summary" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#properties-summary&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 16:26:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302106#M81477</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-06-22T16:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer name from clicking on layer feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302109#M81478</link>
      <description>&lt;P&gt;Thanks! But the correct solution was to use&amp;nbsp;response.results[i].layer.&lt;STRONG&gt;title&lt;/STRONG&gt;, not name.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 16:29:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-name-from-clicking-on-layer-feature/m-p/1302109#M81478</guid>
      <dc:creator>Jackson_CountyMissouri</dc:creator>
      <dc:date>2023-06-22T16:29:48Z</dc:date>
    </item>
  </channel>
</rss>

