Display all attributes in infoWindow popup

1660
1
04-20-2012 05:55 AM
NipaParikh
New Contributor II
Hello,

I would like to format my infowindow to display all fields.  Below is my code display only few fields.  How can I display all attributes.

Please help.

function executeIdentifyTask(evt) {
        identifyParams.geometry = evt.mapPoint;
        identifyParams.mapExtent = map.extent;
      
        var deferred;
       
        for (layerNumber in stateLayerNameArray) {
         if (selState == stateLayerNameArray[layerNumber]) {
           var layerIdArray = new Array();
            for (layer in myESIBaseLayers[selState]) {
              layerIdArray.push(myESIBaseLayers[selState][layer].id);
            }
            identifyParams.layerIds = layerIdArray;
            deferred = identifyTaskArray[layerNumber].execute(identifyParams);
         }
        }
        
        deferred.addCallback(function(response) {    
          // response is an array of identify result objects   
          // Let's return an array of features.
          return dojo.map(response, function(result) {
            var feature = result.feature;
            feature.attributes.layerName = result.layerName;
            if(result.layerName === 'esi lines'){
              console.log(feature.attributes.OBJECTID);
              var template = new esri.InfoTemplate("", "${OBJECTID} <br/> ESI of record: ${ESI}");
              feature.setInfoTemplate(template);
            }
            else if (result.layerName === 'esi polygons'){
              var template = new esri.InfoTemplate("", "ESI: ${ESI}");
              feature.setInfoTemplate(template);
            }
            return feature;
          });
        });


Nipa
0 Kudos
1 Reply
ShreyasVakil
Occasional Contributor II
esri.InfoTemplate(title, content)

Creates a new InfoTemplate object. All parameters are required and must be specified in the order given.

Parameters:

<String> title Required The template for defining how to format the title used in an InfoWindow.
<String> content  Required The template for defining how to format the content used in an InfoWindow.


Code snippets:

Use a wildcard to automatically include all the attribute's name value pairs.

var infoTemplate = new esri.InfoTemplate("Attributes", "${*}");


Display only the specified fields.

infoTemplate = new esri.InfoTemplate("Attributes", "<tr>State Name: <td>${STATE_NAME}
  </tr></td><br><tr>Population:<td>${Pop2001}</tr></td>");
0 Kudos