I am trying to format the info window template and it is not working. here is my code below:
Also, is it possible to change the background color of the info window header through css?
var identify = new esri.tasks.IdentifyTask(".../MapServer");
var identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
identifyParams.returnGeometry = true;
identifyParams.tolerance = 3;
map.infoWindow.clearFeatures();
//Define a good infoTemplate
var infoTemplateUtilities = new InfoTemplate();
infoTemplateUtilities.setTitle("Facility: <b>${FACILITYID}</b>");
infoTemplateUtilities.setContent("MAPREF NUMBER : <b>${MAPREF}</b><br/>" +
"<b>2007 density: </b>${POP07_SQMI:compare}<br/><br/>" +
"<b>2000: </b>${POP2000:NumberFormat}<br/>" +
"<b>2000 density: </b>${POP00_SQMI:NumberFormat}");
try {
identify.execute(identifyParams, function (results) {
map.infoWindow.setFeatures(dojo.map(results, function (result) {
var feature = result.feature;
feature.infoTemplate.setInfoTemplate(infoTemplateUtilities); //<====== This method here does not work at all...
//feature.setInfoTemplate(new esri.InfoTemplate()); //<====== This method here works fine...
return feature;
}));
map.infoWindow.show(evt.mapPoint);
});
}
catch (ex) {
alert(ex.toString());
}
Solved! Go to Solution.
Thank you all,
the problem was the legacy.
changed to var infoTemplateUtilities = new esri.InfoTemplate(); and it worked.