require(["esri/dijit/PopupTemplate"], function(PopupTemplate) { /* code goes here */ });
esri/InfoTemplate
and provides support for defining a layout. It can contain the following components:
esri/dijit/InfoTemplate |_esri/dijit/PopupTemplate
Name | Summary |
---|---|
new PopupTemplate(popupInfo, options?) | Create a new PopupTemplate object. |
esri/dijit/PopupTemplate | Download source
Name | Type | Summary |
---|---|---|
content | String | Function | The template for defining how to format the content used in an InfoWindow. |
info | Object | The popup definition defined as a JavaScript object. |
title | String | Function | The template for defining how to format the title used in an InfoWindow. |
Name | Return type | Summary |
---|---|---|
setContent(template) | InfoTemplate | Sets the content template. |
setTitle(template) | InfoTemplate | Sets the title template. |
toJson() | Object | Converts object to its ArcGIS Server JSON representation. |
< > popupInfo |
Required | An object that defines popup content. Field names can be used in the content by specifying the field name in curly brackets, for example {description} . View the Popup Content help topic for information on the object properties. |
< > options |
Optional | Optional parameters. See options list for details. |
options
properties: < > utcOffset |
Optional | Positive or negative offset (in minutes) from UTC. If specified, date fields in the popup will be formatted in the time zone represented by the offset. Positive value indicates offset to the west of UTC, negative otherwise. If offset is not specified, date fields will be formatted in the user's local time zone. |
require([ "esri/dijit/PopupTemplate", ... ], function(PopupTemplate, ... ) { var template = new PopupTemplate({ title: "Age Distribution in {FIPS}", fieldInfos: [ { fieldName: "AGE_UNDER5", visible: true, format: { places: 0 } }, { fieldName: "AGE_5_17", visible: true, format: { places: 0 } }, { fieldName: "AGE_18_21", visible: true, format: { places: 0 } }, { fieldName: "AGE_22_29", visible: true, format: { places: 0 } }, { fieldName: "AGE_30_39", visible: true, format: { places: 0 } }, { fieldName: "AGE_40_49", visible: true, format: { places: 0 } }, { fieldName: "AGE_50_64", visible: true, format: { places: 0 } }, { fieldName: "AGE_65_UP", visible: true, format: { places: 0 } } ], mediaInfos: [ { type: "piechart", value: { fields: [ "AGE_UNDER5", "AGE_5_17", "AGE_18_21", "AGE_22_29", "AGE_30_39", "AGE_40_49", "AGE_50_64", "AGE_65_UP" ] } } ] )}; ... });
Object
> infoInfoTemplate
infoTemplate.setContent("State Name: ${STATE_NAME}");
InfoTemplate
infoTemplate.setTitle("Feature Attributes");