<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to update time slider start and end time using python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1295283#M67777</link>
    <description>&lt;P&gt;Confirming it works&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2023 10:15:09 GMT</pubDate>
    <dc:creator>MartinRust</dc:creator>
    <dc:date>2023-06-02T10:15:09Z</dc:date>
    <item>
      <title>How to update time slider start and end time using python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1288144#M67616</link>
      <description>&lt;P&gt;I have a Web Map in ArcGIS online where I manually created a time slider.&lt;BR /&gt;This map contains feature layers with measurement data for the 7 last days, and I update them daily using &lt;FONT face="courier new,courier"&gt;arcgis.gis.GIS&lt;/FONT&gt; and related modules, so every day the period of the measurement data advances by one day (deleting the data older than 7 days).&lt;/P&gt;&lt;P&gt;My goal is to have Python update the time slider start and end date accordingly - which is what I now do manually every day in Map Viewer, Map Properties, Time Slider Options.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can retrieve the Web Map from the GIS, it is of type&amp;nbsp;&lt;FONT face="courier new,courier"&gt;arcgis.gis.Item&lt;/FONT&gt;, with type="Web Map".&lt;/P&gt;&lt;P&gt;I hope I can somehow use the set_time_extend function as documented in&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.widgets.html#mapview" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/api-reference/arcgis.widgets.html#mapview&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Can I somehow retrieve an &lt;FONT face="courier new,courier"&gt;arcgis.widgets.MapView&lt;/FONT&gt; object from this Item, or convert it, so that I can call the &lt;FONT face="courier new,courier"&gt;set_time_extent&lt;/FONT&gt; function, or is there some other way I can update the time slider?&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 14:07:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1288144#M67616</guid>
      <dc:creator>MartinRust</dc:creator>
      <dc:date>2023-05-11T14:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to update time slider start and end time using python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1294413#M67754</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/663284"&gt;@MartinRust&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below should help you get there. I have commented but let me know if anything needs further clarification.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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"])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can run the first snippet to see that the changes have been applied. Or simply open/refresh the WebMap in a browser.&lt;/P&gt;&lt;P&gt;Just to note: I use this workflow for Classic Map Viewer and have not tested on the New Web Map Viewer.&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 10:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1294413#M67754</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-05-31T10:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to update time slider start and end time using python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1294434#M67755</link>
      <description>&lt;P&gt;Thanks, looks very promising, I've got to the point of retrieving the existing time slider properties and so far it behaves as you documented. I'll try the actual update tomorrow, as my test users are currently using the map, but I'm confident it will work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 11:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1294434#M67755</guid>
      <dc:creator>MartinRust</dc:creator>
      <dc:date>2023-05-31T11:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to update time slider start and end time using python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1295283#M67777</link>
      <description>&lt;P&gt;Confirming it works&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 10:15:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-update-time-slider-start-and-end-time-using/m-p/1295283#M67777</guid>
      <dc:creator>MartinRust</dc:creator>
      <dc:date>2023-06-02T10:15:09Z</dc:date>
    </item>
  </channel>
</rss>

