Since version: 1.16
The popup element profile allows map authors to write expressions that return a dictionary representing either a rich text, fields table, or media (i.e. a chart or an image) popup element. The returned dictionary must follow the Web Map Specification for a popupElement. When the popup opens, the expression will execute using the feature's attributes as variables. The app executing the expression will render the popup element as defined by the expression.
Unlike the Popup profile, this profile allows popup authors to return multiple values within a single element.
Context
The following products implement this profile:
- ArcGIS Maps SDK for JavaScript
- ArcGIS Pro
- ArcGIS Enterprise
- ArcGIS Online
- ArcGIS Maps SDKs for Native Apps
Spatial reference
The spatial reference of the map in which the expression executes determines the execution context's spatial reference.
Time zone
The time zone of the map in which the expression executes determines the execution context's default time zone.
Profile variables
Variable Name | Type | Description |
---|---|---|
$feature | Feature | Provides access to the attributes and geometry of the feature whose popup is to be displayed in the view. |
$layer | FeatureSet | A collection of features in the same layer as the $feature whose popup is displayed in the view. In ArcGIS Online and ArcGIS Enterprise portal, this only applies to feature service layers. |
$map | FeatureSetCollection | A collection of layers in the same map as the $feature whose popup is displayed in the view. In ArcGIS Online and ArcGIS Enterprise portal, this only applies to feature service layers. |
$datastore | FeatureSetCollection | A collection of layers in the same feature service or database as the $feature whose popup is displayed in the view. In ArcGIS Online and ArcGIS Enterprise portal, this only applies to feature service layers. |
Function bundles
Core | Geometry | Data Access | Portal Access
Return types
See the Web Map Specification for popupElement for a list of properties required for constructing a valid popup element dictionary.
Example
Returns a table with the top three crimes in each block group.
var attributes = {};
var fieldInfos = [];
// Query the number of crimes that intersect a selected polygon
var crimes = Intersects($feature, FeatureSetByName($map,"San Diego crimes", ["desc_"]));
// Queries the count of crimes grouped by the "desc_" field
var stats = GroupBy(crimes, ["desc_"], [{ name: "total", expression: "1", statistic: "count" }]);
// Orders the results in descending order by the total count
// excludes crimes that don't have a classification
var topCrimes = Top(OrderBy(Filter(stats, "desc_ <> ''"), "total desc"), 3);
if(Count(topCrimes) == 0){
return {
type: "text",
text: "No crimes committed in this area"
};
}
for(var item in topCrimes){
var num_crimes = item.total;
var crimeType = item["desc_"];
attributes[crimeType] = num_crimes;
Push(fieldInfos, {
fieldName: crimeType
});
}
return {
type: "fields",
fieldInfos: fieldInfos,
attributes: attributes
};