Hi there, I’m James, guest-posting on the Story Maps Developer’s blog. At Esri, I work with nonprofits and international organizations, and collaborate quite often with the Story Maps team. They asked me to share a recent customization I did to a Story Map.
Keeping the story current
One of the great advantages of a Story Map is the ability to convey information in a dynamic fashion. Because the map is live and reads data from services, it can display the most up to date information. Wouldn’t you like the data in your narrative to be equally dynamic, driven from the data? The WHO recently wanted this for their Story Map detailing the worldwide switch of Polio vaccine (UPDATE: sorry, this story map no longer available). In particular, they wanted to show the number of countries that had switched to the new polio vaccine using the latest information in their database, along with the date of report (the area in the red box below). The data was reported as summary text in a table that is part of the service being used in the Story Map:
- Mark a place for the dynamic text in the narrative section.
- Insert the statistic value into the dynamic text section.
Letting it be part of the narrative
To get the statistic, there are two methods, depending on how much data you’re expecting:
- For small datasets, you can query all features and do the processing in the browser. This is what the WHO Story Map does as it is reading a summary table with the text already formatted.
- Use the outStatistics parameter of the query to have the service summarize and then deliver the results. this would be preferred with a service with a lot of features or several different statistics.
Once the query is returned, I need to process the incoming data. Lines 22–24 of my sample just create an array of the feature attributes from the FeatureSet’s array of features, which makes the browser-side processing slightly easier. Since the data is already summarized, I can request the first value from the array of attributes (in WHO’s case, the array has only one attribute set). While not needed, I’m preparing to reuse this code by providing the ability to specify different statistics; SUM and AVERAGE are fairly easy to write.
Where to put the code in the Story Map