stevel

How to attach an infoWindow to a Dynamic Map's Identify results

Discussion created by stevel on Mar 27, 2012
Latest reply on Oct 22, 2012 by adevine
See this Identify sample which runs an IdentifyTask on a Dynamic map service:

dojo.connect(map,"onClick", doIdentify);
identifyTask =new esri.tasks.IdentifyTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer");
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.layerIds =[0,2];


This sample contains pre-prepared HTML to handle the results, depending on which layer they are from:

if (idResult.layerId === 0) {
  if (!bldgResults.displayFieldName) {bldgResults.displayFieldName = idResult.displayFieldName};
  bldgResults.features.push(idResult.feature);
}else if (idResult.layerId === 2) {
  if (!parcelResults.displayFieldName) {parcelResults.displayFieldName = idResult.displayFieldName};
  parcelResults.features.push(idResult.feature);
}

<div id="bldgTab" dojoType="dijit.layout.ContentPane" title="Buildings"></div>
<div id="parcelTab" dojoType="dijit.layout.ContentPane" title="Tax Parcels"></div>




I need to configure this to be dynamic rather than checking "if layer = building, elseif layer = parcel". An option could be to set an infoTemplate (containing the required formatting of the results) while configuring the IdentifyTask.

see line 75:
var idResult = idResults[i];


The result of the IdentifyTask (idResult.feature) is a graphic, so has an infoTemplate property. Can I set the infoTemplate for the layer before the IdentifyTask is run, so that the identifyResults are formatted using the infoTemplate's settings?

Thanks,
Steve

Outcomes