import { createPopupTemplate, createPopupTemplateForFeatureReduction, createFieldsContent, createFieldInfos } from "@arcgis/core/support/popupUtils.js";const { createPopupTemplate, createPopupTemplateForFeatureReduction, createFieldsContent, createFieldInfos } = await $arcgis.import("@arcgis/core/support/popupUtils.js");- Since
- ArcGIS Maps SDK for JavaScript 4.16
Various utils for working with Popup widget functionality.
Functions
createPopupTemplate
Creates a popup template given the specified Config information.
- Signature
-
createPopupTemplate (config: Config, options?: Partial<CreatePopupTemplateOptions>): PopupTemplate | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| config | A configuration object containing properties for creating a PopupTemplate. | | |
| options | Options for creating the PopupTemplate. | |
- Returns
- PopupTemplate | null | undefined
The popup template, or
nullif no fields are set.
- Example
- // Sets the configuration for the popup template.// Each object in this array is autocast as an instance of esri/layers/support/Fieldconst fields = [{name: "NAME",alias: "Name",type: "string"}, {name: "County",alias: "County",type: "string"}, {name: "ALAND",alias: "Land",type: "double"}];const config = {displayField: "County",fields: fields,title: "County land"};// This sets the options to ignore all fields of "date" type and sets two visible fieldsconst templateOptions = {ignoreFieldTypes: ["date"],visibleFieldNames: new Set(["NAME", "ALAND"])};const template = popupUtils.createPopupTemplate(config, templateOptions);featureLayer.popupTemplate = template;
createPopupTemplateForFeatureReduction
- Since
- ArcGIS Maps SDK for JavaScript 4.25
Creates a default popup template to use for FeatureReductionBinning or FeatureReductionCluster visualizations. The template will consist of a list of all the aggregate fields defined in the featureReduction property of the layer.
- Signature
-
createPopupTemplateForFeatureReduction (params: CreatePopupTemplateForFeatureReductionParameters): PopupTemplate | null | undefined
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| params | Parameters for creating a feature reduction popup template. | |
- Returns
- PopupTemplate | null | undefined
The popup template, or
nullif no AggregateFields are set on the feature reduction object.
- Example
- const popupTemplate = popupUtils.createPopupTemplateForFeatureReduction(layer);layer.featureReduction.popupTemplate = popupTemplate;
createFieldsContent
Creates fields content used for populating a PopupTemplate.
- Signature
-
createFieldsContent (config: FieldInfosConfig, options?: Partial<CreatePopupTemplateOptions>): FieldsContent
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| config | A configuration object containing properties for creating FieldsContent. | | |
| options | Options for creating the PopupTemplate. | |
- Returns
- FieldsContent
The
fieldscontent used to populate the PopupTemplate. This content contains an array of FieldInfo.
- Example
- // Sets the configuration for the popup template.// Each object in this array is autocast as an instance of esri/layers/support/Fieldconst fields = [{name: "NAME",alias: "Name",type: "string"}, {name: "County",alias: "County",type: "string"}, {name: "ALAND",alias: "Land",type: "double"}];// This sets the options to ignore all fields of "date" type and sets two visible fieldsconst templateOptions = {ignoreFieldTypes: ["date"],visibleFieldNames: new Set(["NAME", "ALAND"])};// Set the FieldInfoconst fieldsConfig = {fields: fields};// Create the Fields Contentconst fieldsContent = popupUtils.createFieldsContent(fieldsConfig, templateOptions);// Create the template and pass in the fields contentconst template = {title: "County Land",outFields: ["*"],content: [fieldsContent]};// Set the feature layer's popup templatefeatureLayer.popupTemplate = template;
createFieldInfos
Creates an array of FieldInfo used for populating FieldsContent.
- Signature
-
createFieldInfos (config: FieldInfosConfig, options?: Partial<CreatePopupTemplateOptions>): FieldInfo[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| config | A configuration object containing properties for creating FieldInfo. | | |
| options | Options for creating the PopupTemplate. | |
- Returns
- FieldInfo[]
An array of FieldInfo content used to populate the FieldsContent, which in turn is used to populate the PopupTemplate. By default, system fields, e.g.
Shape__AreaandShape__Length,OID, etc, do not display.
- Example
- // Sets the configuration for the popup template.// Each object in this array is autocast as an instance of esri/layers/support/Fieldconst fields = [{name: "NAME",alias: "Name",type: "string"}, {name: "County",alias: "County",type: "string"}, {name: "ALAND",alias: "Land",type: "double"}];// This sets the options to ignore all fields of "date" type and sets two visible fieldsconst templateOptions = {ignoreFieldTypes: ["date"],visibleFieldNames: new Set(["NAME", "ALAND"])};// Set the FieldInfoconst fieldsConfig = {fields: fields};// Create the FieldInfosconst fieldInfos = popupUtils.createFieldInfos(fieldsConfig, templateOptions);// Sets the FieldsContentconst fieldsContent = new FieldsContent({fieldInfos: fieldInfos});// Create the template and pass in the fields contentconst template = {title: "County Land",outFields: ["*"],content: [fieldsContent]};// Set the feature layer's popup templatefeatureLayer.popupTemplate = template;
Type definitions
FieldInfosConfig
A configuration object containing field properties for creating FieldsContent for a PopupTemplate.
editFieldsInfo
- Type
- EditFieldsInfo | null | undefined
The fields that record who adds or edits data in the feature service and when the edit is made.
- Example
- // Sets the configuration for the popup template.// Each object in this array is autocast as an instance of esri/layers/support/Fieldconst fieldsConfig = [{name: "NAME",alias: "Name",type: "string"}, {name: "County",alias: "County",type: "string"}, {name: "ALAND",alias: "Land",type: "double"}];
Config
A configuration object containing properties for creating a PopupTemplate.
- Supertypes
- FieldInfosConfig
- Example
- // Sets the configuration for the popup template.// Each object in this array is autocast as an instance of esri/layers/support/Fieldconst fields = [{name: "NAME",alias: "Name",type: "string"}, {name: "County",alias: "County",type: "string"}, {name: "ALAND",alias: "Land",type: "double"}];const config = {displayField: "County",fields: fields,title: "County land"};
CreatePopupTemplateForFeatureReductionParameters
CreatePopupTemplateOptions
Options for creating the PopupTemplate.
visibleFieldNames
An array of field names set to be visible within the PopupTemplate.
- Example
- // This sets the options to ignore all fields of "date" type and sets two visible fieldsconst templateOptions = {ignoreFieldTypes: ["date"],visibleFieldNames: new Set(["NAME", "ALAND"])};