<?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: Can I populate an InfoWindow with the selected feature's label? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281542#M26002</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see, so it is the label value that was specified in the symbology before it got published. Let me do some research to see how that is accessible or somebody might already know it and post it here &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 May 2015 20:00:53 GMT</pubDate>
    <dc:creator>TimWitt2</dc:creator>
    <dc:date>2015-05-14T20:00:53Z</dc:date>
    <item>
      <title>Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281539#M25999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm consuming a service that has symbology set up based on unique values of a particular field.&amp;nbsp; The way the service is set up, each symbology type has a label different than the actual unique value (as an example, one value is "Anthropogenic_Oyster_Reef" which is labeled as "Man-Made Oyster Reef").&amp;nbsp; I have a legend which displays the labels of the various symbology types, but when a user clicks a feature they're going to see the actual field value ("Anthropogenic_Oyster_Reef") instead of the label we've provided in the legend ("Man-Made Oyster Reef").&amp;nbsp; This can be confusing for our users.&amp;nbsp; Is there a way to retrieve the label of the feature when clicking it, or is my only option to edit the service so the field values match the desired labels?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm sure I could use some if statements to check for each possible field value and return the label name, but I feel like that would be extremely sloppy and there must be a better way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 19:29:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281539#M25999</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2015-05-14T19:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281540#M26000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Brett,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where is the label value for each feature stored?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 19:34:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281540#M26000</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-14T19:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281541#M26001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure.&amp;nbsp; I tried looking through the object returned when you click a feature in the console, but I don't see the label stored anywhere in there.&amp;nbsp; It's obviously stored somewhere because the legend is able to retrieve that information.&amp;nbsp; Here's a link to the service I'm using if that will help: &lt;A href="http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/0" title="http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/0"&gt;http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/0&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 19:51:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281541#M26001</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2015-05-14T19:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281542#M26002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see, so it is the label value that was specified in the symbology before it got published. Let me do some research to see how that is accessible or somebody might already know it and post it here &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 20:00:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281542#M26002</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-14T20:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281543#M26003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brett,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What if you add a field to your data named "LABEL" and then just do a select by attribute and calculate it with the label values. After you re-publish it, you can just use this label field in your pop-up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just an idea if nobody is able to tell you how to access the Label that the legend widget accesses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 May 2015 20:20:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281543#M26003</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-14T20:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281544#M26004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The labels are probably defined in the MXD that was used to publish the data so, more than likely, they were never actually part of the dataset's attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways, I suppose you could retrieve a copy of the layer's legend in JSON format using the REST API:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/legend?f=json" title="http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/legend?f=json" rel="nofollow noopener noreferrer" target="_blank"&gt;http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/legend?f=json&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JS code wise, something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var url = "&lt;A href="http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/legend?f=json" title="http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/legend?f=json" rel="nofollow noopener noreferrer" target="_blank"&gt;http://geodata.md.gov/imap/rest/services/Biota/MD_BenthicHabitat/MapServer/legend?f=json"&lt;/A&gt;;
var requestHandle = esriRequest({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: url,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; content: {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f: 'json'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs: "json"
});

requestHandle.then(
&amp;nbsp;&amp;nbsp;&amp;nbsp; function (theJSON, io) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //no problems encountered. Process content stored in theJSON..
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (err) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Error encountered while retrieving the JSON version of the legend..
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
};&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above would need AMD references for "dojo/_base/json", "esri/urlUtils", and "esri/request"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you could do is step through the legend information and maybe build an array of code/labels. When your user clicks on a feature, use an infoWindow setContent function to look up the matching label and present whatever information you want to your users.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:38:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281544#M26004</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2021-12-11T13:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can I populate an InfoWindow with the selected feature's label?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281545#M26005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Steve.&amp;nbsp; I figured that would probably end up being the case.&amp;nbsp; I'll probably just see about going and adding another field for the label.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 12:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-i-populate-an-infowindow-with-the-selected/m-p/281545#M26005</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2015-05-15T12:10:40Z</dc:date>
    </item>
  </channel>
</rss>

