Do you want to include a time-enabled layer in your custom web map? Is the temporal extent of your time-enabled layer changing as the content changes? If so, your web map must also keep up with the changing time extent. This can be easily done by adjusting the web map time settings. The Web Map properties, such as the time settings, can be precisely accessed and updated using ArcGIS API for Python in ArcGIS Notebooks. In this blog I’ll show you how to adjust the Web Map time slider settings to display the correct time extent of a changing time-enabled layer using as an example custom web map that contains a time-enabled layer.
Some background info
A web map containing time-enabled layers, such as those available as Live Feeds are known as time web maps. Time web maps have a time slider which controls the display of content from layers as they change over time. Examples of time web maps in ArcGIS Living Atlas of the World are the Arctic Sea Ice Artic Extent, the National Weather Service Wind Speed Forecast for the USA, or the National Water Model (hourly forecast).
The time extent (i.e., start and end times) of a Live Feed layer change regularly. They display a moving window of content, like a forecast for the next 10-days, or they display content starting from a fixed point in time and appending new values as they become available, such as observations from 1970 to the present. In any case, a custom web map that includes a time-enabled layer, like a Live Feed layer, must display the correct time extent in the time slider settings.
Saving the web map time settings
A problem arises when creating and saving a time web map with a layer that updates automatically as time goes on. The time slider settings are stored (i.e., hard-coded values) within the web map, however, when an automatic update occurs (i.e. changing the start and end time extents), the web map is not aware of the change. The next time the web map is opened, it displays the old, now incorrect time settings and not the current time extent of the time-enabled layer.
Adjusting the time settings of a web map
The time extent on the time settings of a web map can be removed, clearing out the hard-coded values and forcing the map to query for the time extent of the time-enabled layer. In the following example, I’ll adjust the time settings on a web map that includes the National Water Model (hourly forecast) layer, so that the proper time extent displays.
Example: Adjusting time on a web map
Creating a web map
The NWM (1 hour forecast) web map includes the National Water Model (Hourly Forecast) time-enabled layer from Living Atlas. The web map was created and saved on August 01, 2019 2:00 pm PST. The map displays the right forecast from 08/01/2019 2:00 pm to 02/02/2019 7:00 am PST.
The National Water Model (hourly forecast) displays the same time extent in its REST endpoint, from 08/01/2019 9:00 pm to 02/02/2019 9:00 pm UTC.
Accessing the web map later in time
An hour later, we viewed the map after the National Water Model (hourly forecast) layer automatically updated using its feed routine. The REST endpoint now shows the forecast time advanced 1 hour, from 08/01/2019 9:00 pm to 02/02/2019 9:00 pm UTC.
However, the start time on the web map still shows one hour behind so the map does not display the latest forecast.
We fix this issue by removing the time extent properties of the web map, forcing it to retrieve the time extent from the National Water Model (hourly forecast) layer when the map is reloaded.
Editing the time properties of a web map using the ArcGIS API for Python
Open an ArcGIS Notebook in ArcGIS Enterprise or in your desktop.
Load the required modules.
Connect to your ArcGIS Online or ArcGIS Enterprise account.
Note: For layers that require login, you use a stored profile for authentication or you provide your username and password. The ArcGIS API for Python documentation has information on working with different authentication schemes.
Get the web map item by providing its item id.
Get the web map item data as a dictionary and delete the ‘startTime’ and the ‘endTime’ properties of the time slider widget.
Note: If your time-enabled layer has a fixed ‘startTime’ and data is appended at the end (i.e., moving ‘endTime’), you can remove only the ‘endTime’ property on the time slider and allow the web map to discover it automatically from the time-enabled layer.
Update the web map item details.
Now the NWM (1 hour forecast) web map displays the correct time extent after it’s refreshed on the webpage.
After updating the time slider settings, the ‘startTime’ and ‘endTime’ properties are blank (i.e., the values are no longer hard-coded). The web map will query for the time extent settings from the time-enabled layer when the web map is loaded.
Note: If we modify the time slider settings on the web map and save it, the time extent properties will be saved as part of the online item. We’ll have the initial problem in which the ‘startTime’ and ‘endTime’ properties are stored (i.e., hard-coded values). If this happens, just repeat the same workflow to delete the time extent properties once again.
Join GeoNet and ask a question to our community of experts.
I would like to acknowledge Paul Dodd for providing the workflow presented in this blog.