Class: InfoTemplateE-mail This Topic Printable Version Give Us Feedback

Description

An InfoTemplate contains a title and content template string used to transform Graphic.attributes into an HTML representation. The Dojo syntax ${<key>} performs the parameter substitution. In addition, a wildcard ${*} can be used as the template string. The wildcard prints out all of the attribute's name value pairs. The default behavior on a Graphic is to show the Map's InfoWindow after a click on the Graphic. An InfoTemplate is required for this default behavior.

Class hierarchy

esri.InfoTemplate

Constructor

Constructor Description
esri.InfoTemplate() Creates a new empty InfoTemplate object.
esri.InfoTemplate(title, content) Creates a new InfoTemplate object. All parameters are required and must be specified in the order given.
esri.InfoTemplate(json) Creates a new InfoTemplate object using a JSON object.

Properties

Property Type Description
content String The template for defining how to format the content used in an InfoWindow.
title String The template for defining how to format the title used in an InfoWindow.

Methods

Method Return Value Description
setContent(template) InfoTemplate Sets the content template.
setTitle(template) InfoTemplate Sets the title template.
toJson() Object Converts object to its ArcGIS Server JSON representation.
Constructor Detail

esri.InfoTemplate()

Creates a new empty InfoTemplate object.

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

esri.InfoTemplate(json)

Creates a new InfoTemplate object using a JSON object.
Parameters:
<Object> json Required JSON object representing the InfoTemplate.

{title:"Test Title", content:"Test Content"}
Code snippets:
var json = {title:"Attributes",content:"<tr>State Name: <td>${STATE_NAME}</tr>
  </td><br><tr>Population: <td>${POP2001}</tr></td>}
infoTemplate = new esri.InfoTemplate(json);
Properties Detail

<String> content

The template for defining how to format the content used in an InfoWindow.

<String> title

The template for defining how to format the title used in an InfoWindow.
Methods Detail

setContent(template)

Sets the content template.
Return value: InfoTemplate
Input Parameters:
<String> template Required The template for the content.
Code snippets:
infoTemplate.setContent("<tr>State Name: <td>${STATE_NAME}</tr></td>")

setTitle(template)

Sets the title template.
Return value: InfoTemplate
Input Parameters:
<String> template Required The template for the title.
Code snippets:
infoTemplate.setTitle("Feature Attributes");

toJson()

Converts object to its ArcGIS Server JSON representation.
Return value: Object