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 | Since version |
---|---|---|---|
$feature | Feature | Provides access to the attributes and geometry of the feature whose popup is to be displayed in the view. | 1.16 |
$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. | 1.16 |
$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. This value may be null in cases where a popup is not associated with a map. | 1.16 |
$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. | 1.16 |
$userInput | Geometry | A geometry representing a user's input for a popup. Typically, this represents a location where the user clicked or tapped in a map to launch a popup. There may be cases where this value is a Point, an Extent, or null as popups are not always opened from map interaction. Therefore, it is advised to check the geometry type of this value before it is used. | 1.26 |
$graph | KnowledgeGraph | A knowledge graph associated with the feature. If no knowledge graph is available, the value will be null . | 1.26 |
Function bundles
Core | Geometry | Data Access | Portal Access | Knowledge Graph
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
};