<?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 Formatting an InfoWindow in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705229#M65636</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my application, I have a map service containing many different layers, each containing many different fields. In the mxd file that created the service, we have hidden all the fields in each layer that don't need to be shown. When the user clicks on the map, I run the IdentifyTask and I'd like to show the user which layer is being represented in the InfoWindow when there are results from different layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Currently, using the code &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var deferred = identifyTask.execute(identifyParams);&amp;nbsp; deferred.addCallback(function (response) { &amp;nbsp;&amp;nbsp;&amp;nbsp; // response is an array of identify result objects&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Let's return an array of features. &amp;nbsp;&amp;nbsp;&amp;nbsp; return dojo.map(response, function (result) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var feature = result.feature; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.attributes.layerName = result.layerName; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //var infoTemplate = new esri.InfoTemplate('${result.layerName}', "${*}"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var infoTemplate = new esri.InfoTemplate("test", "${*}"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infoTemplate.setTitle("testing"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.setInfoTemplate(infoTemplate); &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; return feature; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gives me an InfoWindow with the layer name appended to the end of the list of fields. How can I format the infoWindow so that the layerName is at the top of the field list? Setting the title doesn't seem to have any effect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]23729[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Apr 2013 18:14:54 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2013-04-23T18:14:54Z</dc:date>
    <item>
      <title>Formatting an InfoWindow</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705229#M65636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my application, I have a map service containing many different layers, each containing many different fields. In the mxd file that created the service, we have hidden all the fields in each layer that don't need to be shown. When the user clicks on the map, I run the IdentifyTask and I'd like to show the user which layer is being represented in the InfoWindow when there are results from different layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Currently, using the code &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var deferred = identifyTask.execute(identifyParams);&amp;nbsp; deferred.addCallback(function (response) { &amp;nbsp;&amp;nbsp;&amp;nbsp; // response is an array of identify result objects&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Let's return an array of features. &amp;nbsp;&amp;nbsp;&amp;nbsp; return dojo.map(response, function (result) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var feature = result.feature; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.attributes.layerName = result.layerName; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //var infoTemplate = new esri.InfoTemplate('${result.layerName}', "${*}"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var infoTemplate = new esri.InfoTemplate("test", "${*}"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infoTemplate.setTitle("testing"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.setInfoTemplate(infoTemplate); &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; return feature; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gives me an InfoWindow with the layer name appended to the end of the list of fields. How can I format the infoWindow so that the layerName is at the top of the field list? Setting the title doesn't seem to have any effect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]23729[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 18:14:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705229#M65636</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2013-04-23T18:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting an InfoWindow</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705230#M65637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm making some progress on this by getting the attributes from the graphic. However, I'm running into a problem with the object that's returned from the line "features.attributes". The line&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var sp = feature.attributes;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;returns this object&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Object { OBJECTID="5", County Name= "Palm Beach County",&amp;nbsp; more...}&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I try to loop through sp with the code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var sp = feature.attributes;
contentString += result.layerName;
for (x in sp) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; contentString += "&amp;lt;br/&amp;gt;";
&amp;nbsp;&amp;nbsp;&amp;nbsp; contentString += x;
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the value for x is just the attribute name, not the attribute and its value. That code results in a contentString with a value of&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;"Study Counties - SEFCRI Region Boundary&amp;lt;br/&amp;gt;OBJECTID&amp;lt;br/&amp;gt;County Name&amp;lt;br/&amp;gt;County Seat"&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I parse out the attributes object correctly?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:38:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705230#M65637</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-12T05:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting an InfoWindow</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705231#M65638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;With a little more digging, I solved it with this code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var sp = feature.attributes; contentString += "&amp;lt;b&amp;gt;" + result.layerName + "&amp;lt;/b&amp;gt;";&amp;nbsp; for (x in sp) { &amp;nbsp;&amp;nbsp;&amp;nbsp; contentString += "&amp;lt;br/&amp;gt;"; &amp;nbsp;&amp;nbsp;&amp;nbsp; contentString += x + ": " + feature.attributes&lt;X&gt;; }&lt;/X&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 12:12:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/formatting-an-infowindow/m-p/705231#M65638</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2013-04-25T12:12:53Z</dc:date>
    </item>
  </channel>
</rss>

