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
Properties
| 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
Constructor Detail
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>);
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
The template for defining how to format the content used in an
InfoWindow.
The template for defining how to format the title used in an
InfoWindow.
Methods Detail
Sets the content template.
Input Parameters:
|
<String> template |
Required |
The template for the content. |
Code snippets:
infoTemplate.setContent("<tr>State Name: <td>${STATE_NAME}</tr></td>")
Sets the title template.
Input Parameters:
|
<String> template |
Required |
The template for the title. |
Code snippets:
infoTemplate.setTitle("Feature Attributes");
Converts object to its ArcGIS Server JSON representation.
Return value: Object