Format Info Window Content

1313
10
Jump to solution
09-24-2014 08:07 AM
RichardMoussopo
Occasional Contributor III

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());

        }

     

0 Kudos
10 Replies
RichardMoussopo
Occasional Contributor III

Thank you all,

the problem was the legacy.

changed to var infoTemplateUtilities = new esri.InfoTemplate(); and it worked.

0 Kudos