Hi @MartinRust
The below should help you get there. I have commented but let me know if anything needs further clarification.
from arcgis import GIS
## access AGOL
agol = GIS("home")
## use the WebMap item ID to get the WebMap
wm_item = agol.content.get("WM_ITEM_ID")
## access the WebMap Item JSON Data
wm_data = wm_item.get_data()
## print the current time slider information to screen.
print(wm_data["widgets"]["timeSlider"])
The above will let you see the makeup of the Time Slide JSON. In the continued snippet below we will use the printed information and you can alter any of the properties you need to.
from arcgis import GIS
## access AGOL
agol = GIS("home")
## use the WebMap item ID to get the WebMap
wm_item = agol.content.get("WM_ITEM_ID")
## access the WebMap Item JSON Data
wm_data = wm_item.get_data()
## print the current time slider information to screen.
print(wm_data["widgets"]["timeSlider"])
## update the properties in the below dictionary
## you could use variables to inject in start/end time
## check out documentation for propertues information
## for example esriTimeUnitsDays, esriTimeUnitsMonths
update_timeSlider = {
'properties': {
'startTime': 1622044320000,
'endTime': 1663853100000,
'thumbCount': 2,
'thumbMovingRate': 2000,
'timeStopInterval': {
'interval': 4,
'units': 'esriTimeUnitsDays'
}
}
}
## apply the updates to the timeSlider property in the widgets
wm_data["widgets"]["timeSlider"] = update_timeSlider
## updaate the JSON for the WebMap Item
wm_item_properties = {"text":wm_data}
wm_item.update(item_properties=wm_item_properties)
You can run the first snippet to see that the changes have been applied. Or simply open/refresh the WebMap in a browser.
Just to note: I use this workflow for Classic Map Viewer and have not tested on the New Web Map Viewer.
Hope it helps.
~ learn.finaldraftmapping.com