HOW TO
When configuring pop-ups for feature layers, the content and how the content is displayed can be customized. Pop-up elements support related data, hyperlinks, ArcGIS Arcade expressions, and HTML mode.
Arcade can perform mathematical calculations, manipulate text, and evaluate logical statements. It also supports multi-statement expressions, variables, and flow control statements. Arcade was designed specifically for creating custom visualizations and labeling expressions in the ArcGIS Platform.
It is intended for evaluating embedded expressions such as those used in the visualization, labeling, popup, and alias contexts of applications built with the ArcGIS platform. It can only be executed within the context of a designated profiles, such as labeling, visualization, popups, calculation, and constraints. Each profile defines the parameters that are available to the script as global variables, and the output expected from the script.
The steps to view a 'grouped by count' of features that are spatially related to the identified feature in the map are as follows.
// Reference the sample points feature layer var samples = FeatureSetByName($map,"samples") // Count the number of samples within each polygon var sampleCount = Intersects(samples, $feature) // Group samples by their date and count var stats = GroupBy(sampleCount, "Year", [ {name: "NumSamples", expression: "1", statistic: "COUNT"} ]) // Order the results in descending order by the total counts var topSamples = OrderBy(Filter(stats, "Year <> ''"), "Year desc") // Popup placeholder var result = 'Number of samples per year:' // Write the results to the popup if(Count(topSamples) == 0){ return "No samples in this area" } var num = 0 // Format the results for display in popup for(var item in topSamples){ num++ var num_samples = item["NumSamples"] var sample_year = item["Year"] result += TextFormatting.NewLine + num + ". " + sample_year + ": " + num_samples } return result
Identifying polygon features displays a popup with the summarized results
Get help from ArcGIS experts
Download the Esri Support App